What do others think of the crippled new EntitySet?
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1968147&SiteID=1
I understand the reason cited for dropping IQueryable support, but the cost seems excessive...
For a start, there's a confusing lack of symmetry now. The following Northwind query, for instance, executes entirely on the server, as an efficient SQL query:
from e in dataContext.Employees
where e.City == "Redmond"
select new
{
e.Title,
TotOrders = e.Orders.Count
};
Yet the next query pulls every order processed by an employee to the client, which is highly inefficient:
var queryClient =
{
emp.Title,
TotOrders = emp.Orders.Count
};
This can be worked around by restructuring the query, but why allow such a trap in the first place? And how do you go about explaining to a newbie why the first query doesn't also cause this inefficiency, without making LINQ seem complex and nuanced? The confusion is further exacerbated by the fact thatdataContext.Orders.Count()does execute efficiently.
A more important issue is that lack of IQueryable support in EntitySet kills query composability. For instance, it's now impossible to write the following method:
{
var queryServer =
from e in dataContext.Employees
select new
{
e.Title,
e.FirstName,
e.LastName,
...
TotalOrderCount = e.Orders.Count,
SelectedOrders = e.Orders.Where (orderFilter)
};
...
}
This will not compile - and right now there is no intuitive workaround. The dynamic query sample cannot help out becausee.Ordersdoes not implement IQueryable<>.
The only viable solution is to copy and paste this method for each predicate variation. But is this really where we want to head?
Joe

