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;

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


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


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