Last week, I spoke at an EF session for the french ALT .NET community.
During its course, I made a WCF demo with EF POCO and a sort of LINQ provider in the client part.
This provider is very simplistic (made in less than 15 minutes), isn’t thread safe but is interesting for the POC and because if my provider doesn’t support a LINQ method, it will use LINQ To Object method.
I just want to come back on this provider, which is very different than normal LINQ providers, and particularly on this code:
public static class CategoryClient
public static MyQueryable<Category> Categories
ClientLINQ.AllEntities = true;
private static IEnumerable<Category> GetCategories()
value = Context.Instance.CategoryContract.GetAllCategories();
value = Context.Instance.CategoryContract.GetCategories(ClientLINQ.IncludeValues, ClientLINQ.WhereValue, ClientLINQ.OrderByValue, ClientLINQ.SkipValue, ClientLINQ.TakeValue);
foreach (var category in value)
yield return category;
How does it work? The set of AllEntities to true initializes IncludeValues, WhereValues, etc
IncludeValues = null;
WhereValue = null;
OrderByValue = null;
SkipValue = 0;
TakeValue = 0;
How can AllEntities be false in GetCategories method whereas the instruction which follows AllEntities = true is the GetCategories call and this method starts with a test on AllEntities ?
In fact, you should see that this method uses yield return syntax. So, it will be run only when Categories properties will be iterated. This means that the different LINQ methods are called before. That’s why it’s works.