You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EFGraphDiff is a huge help when saving, but I've found I come up wanting when loading for a couple of reasons, and I want to focus in on the big one here: OrderBy.
EFGraphDiff doesn't use an OrderBy when loading an Entity's child Collections from the db.
Performance: I've found that unordered queries against Sql Server Web Edition are far slower than any query with an OrderBy that can use an Index.
Consistency: Many use cases and interfaces require a particular sort order.
These combine to mean EFGraphDiff's loading capabilities are in the way of the right way of loading these Entities. I've put together code that lets you declaratively mark a class with how you'd like it ordered when loading as a child of a query. I've not addressed this but it would be reasonably easy to override the declarations when you want to via a config.
I can just post it as a separate library and people can combine them if they wish, but this does seem like a blindspot for EFGraphDiff so I wonder if this or some portion of it belongs in EFGraphDiff. The work was relatively significant since it requires emitting custom classes (that act like a runtime Anonymous class) and then asking EF to fill them with custom Select statements that are the sum of many, many Lambda Expressions.
For example:
var propColl = Expression.Property(selectParam, dbProp);
var orderByParam = Expression.Parameter(itemType, "p");
var orderIndexProp = itemType.GetProperty(orderedPropName);
var orderByExp = Expression.Lambda(
Expression.MakeMemberAccess(orderByParam, orderIndexProp),
orderByParam
);
var orderedProp = Expression.Call(
typeof(Enumerable), "OrderBy",
new[] { itemType, typeof(int) },
propColl,
orderByExp
);
var bindSetter = Expression.Bind(runtimeProp.SetMethod, orderedProp);
Just wanted to start the discussion. If I post this as a separate library as well I'll link back here.
The text was updated successfully, but these errors were encountered:
This is less of an Issue and more a Discussion.
EFGraphDiff is a huge help when saving, but I've found I come up wanting when loading for a couple of reasons, and I want to focus in on the big one here: OrderBy.
EFGraphDiff doesn't use an OrderBy when loading an Entity's child Collections from the db.
These combine to mean EFGraphDiff's loading capabilities are in the way of the right way of loading these Entities. I've put together code that lets you declaratively mark a class with how you'd like it ordered when loading as a child of a query. I've not addressed this but it would be reasonably easy to override the declarations when you want to via a config.
I can just post it as a separate library and people can combine them if they wish, but this does seem like a blindspot for EFGraphDiff so I wonder if this or some portion of it belongs in EFGraphDiff. The work was relatively significant since it requires emitting custom classes (that act like a runtime Anonymous class) and then asking EF to fill them with custom Select statements that are the sum of many, many Lambda Expressions.
For example:
Just wanted to start the discussion. If I post this as a separate library as well I'll link back here.
The text was updated successfully, but these errors were encountered: