Entity Framework .Include() with compile time checking?
Posted
by Mikey Cee
on Stack Overflow
See other posts from Stack Overflow
or by Mikey Cee
Published on 2010-05-27T12:37:50Z
Indexed on
2010/05/27
12:41 UTC
Read the original article
Hit count: 196
.NET
|entity-framework
Consider the following code, which is calling against an EF generated data context:
var context = new DataContext();
var employees = context.Employees.Include("Department");
If I change the name of the entity Department then this code is going to start throwing a runtime error. So I'll have to do some kind of find and replace throughout my code to replace each occurrence of "Department".
Is there any way to call the .Include() method in a safe manner, so I get compile time checking for all the entity names being referenced?
© Stack Overflow or respective owner