Last post Jan 04, 2012 02:49 AM by Diego79
Jan 03, 2012 08:48 PM|Diego79|LINK
I created my first Dynamic Data 4 web site, with the model-first approach. I created my model (MyModel.edmx), my entities (Employee, Project, Client, etc.) and my SQL Server database, and I also registered the DataContext in global.asax and allowed scaffolding
for all the entities.
Everything works fine.
Now, in a custom page, I only want to execute a linq query, i.e.: var q = from e in context.Employee where e.Name = "Tom" select e;
But... the "context" variable? Visual Web Developer created a MyModelContainer class derived from ObjectContext, but if I try to use it the editor tells me that MyModelContainer "does not contain a definition for Employee".
My question is: how I get the right ObjectContest to use in my linq queries?
Jan 04, 2012 02:49 AM|Diego79|LINK
The correct syntax to get the context is MyModelContainer contex = new MyModelContainer().