score:3

Accepted answer

since you're using linqtosql, you should use datacontext.loadwith when you fetch your objects. this is the preferred way of telling linqtosql what it should pull down (since it defaults to lazy load).

dataloadoptions options = new dataloadoptions();
options.loadwith((employee c) => c.rota);
db.loadoptions = options;

http://msdn.microsoft.com/en-us/library/system.data.linq.dataloadoptions.loadwith.aspx

this has the benefit of being far more efficient on the sql-side when compared with calling tolist or expanding entityref properties individually.

score:0

i assume rota is contained in a collection. set the collection type as list<rota>, this should work if this is the case.

score:0

you are on the right track already - the query only gets executed once you iterate it (inspecting it in debug mode causes this iteration as well). just call tolist() on the iqueryable (thus iterating it) before sending it through the web service.


Related Query