Goal: To pass a list of related objects into a view which can then be iterated over using razor syntax.
I'm new to LINQ and MVC4. I'm trying to use the repository pattern to manage my model creation. I have set up a series of SQL database tables, and generated a DBML file using LINQ to SQL.
Now I seem to have two model style classes, one in the DBML file which was auto-generated.
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Projects")]
public partial class Project : INotifyPropertyChanging, INotifyPropertyChanged
{
private static PropertyChangingEventArgs emptyChangingEventArgs = ...
private int _Id;
private string _Title;
...
}
And the other in a folder which i've manually created:
namespace Models
{
public class Project
{
public Project(int ID, string Title, List<Group> Groups)
{
this.ID = ID;
this.Title = Title;
this.Groups = Groups;
}
public int ID { get; set; }
public string Title { get; set; }
public List<Group> Groups { get; set; }
}...
When I use attempt to get all projects through the repository it errors if I pass
return Context.GetTable<Models.Project>();
Which results in the following error:
Server Error in '/' Application.
The type 'Nimble.Models.Project' is not mapped as a Table.
Should I just bin my models, and use the models created by the LINQ to SQL?