A patch to fix three bugs and expose one small, but useful feature.
Description
The proposed patch fixes the following three bugs: 1. BinaryCriterionVisitor was missing VisitMemberAccess, which does get called in our application. 2. WhereArgumentsVisitor incorrectly handled the Equals method. The old implementation only worked correctly on string properties. In our case, the particular property was a struct and so it failed. The proposed fix delegates the handling of the Equals method to VisitBinaryCriterionExpression replacing the method call Equals with the operator ==. 3. The RootVisitor did not handle the Cast method. The proposed fix handles Cast exactly the same way as OfType is handled today - does nothing.
In addition we would like to have the following ISession extension method: public static void List<T>(this ISession session, Expression expr, IList list); What it does is fetch the objects satisfying the given linq expression and appends them to the given list, which ultimately corresponds to the ICriteria.List method with the same semantics. We find this feature useful, because in our application a single expression may trigger the fetch of objects of multiple types, all of which are appended to the same list. Before switching to the linq expressions we have enjoyed the natural ICriteria support of this feature.
The proposed patch fixes the following three bugs:
1. BinaryCriterionVisitor was missing VisitMemberAccess, which does get called in our application.
2. WhereArgumentsVisitor incorrectly handled the Equals method. The old implementation only worked correctly on string properties. In our case, the particular property was a struct and so it failed. The proposed fix delegates the handling of the Equals method to VisitBinaryCriterionExpression replacing the method call Equals with the operator ==.
3. The RootVisitor did not handle the Cast method. The proposed fix handles Cast exactly the same way as OfType is handled today - does nothing.
In addition we would like to have the following ISession extension method:
public static void List<T>(this ISession session, Expression expr, IList list);
What it does is fetch the objects satisfying the given linq expression and appends them to the given list, which ultimately corresponds to the ICriteria.List method with the same semantics. We find this feature useful, because in our application a single expression may trigger the fetch of objects of multiple types, all of which are appended to the same list. Before switching to the linq expressions we have enjoyed the natural ICriteria support of this feature.