What should i return from a WCF service when using LINQ? e.g.:
var res = from q in context.cust
select q;
The LINQ follows Deferred Execution and thus the statement doesn’t do anything until a for loop is ran. This means i can’t just return res. Then what should i return? Do i need to write a for loop and populate objects and return it’s List every time i want to return data from WCF service? Is there no equivalent of ADO.NET DataSet which follows disconnected architecture and is ideal for moving data between different tiers and from web service or WCF service?
Execution is deferred until the data is actually requested, you’re right that that may be a for loop but it would also be when it needs to be serialized for transfer via WCF. If you make your WCF service return IEnumerable then the query will be executed and the results returned.