Entity Framework (4.0) how to exclude a related table.
Posted
by Kohan
on Stack Overflow
See other posts from Stack Overflow
or by Kohan
Published on 2010-05-06T15:21:48Z
Indexed on
2010/05/07
5:38 UTC
Read the original article
Hit count: 213
I have just updated to using EF 4.0 where before i was using Linq 2 SQL.
I have a query:
var UserList = this.repository.GetUsers();
return Json(UserList, JsonRequestBehavior.AllowGet);
This was generating an error: "A circular reference was detected while serializing an object of type
"
This prompted this code which worked fine in L2S:
var UserList = this.repository.GetUsers();
foreach (User u in UserList){
u.Subscriptions = null;
}
return Json(UserList, JsonRequestBehavior.AllowGet);
How can i stop EF from looking into the Subscriptions table, i just want the Userlist, none of the related properties and the above example does not seem to work for this.
Cheers, Kohan
© Stack Overflow or respective owner