There is a fairly simple way to take IQueryOver , find its basic criteria and add one, see https://gist.github.com/2304623
public static IQueryOver<TRoot, TSubType> WhereBitwiseRestriction<TRoot, TSubType>( this IQueryOver<TRoot, TSubType> query , Expression<Func<TSubType, object>> expression , int number) { var name = ExpressionProcessor.FindMemberExpression(expression.Body); query.UnderlyingCriteria.Add ( BitwiseRestrictions.AtLeastOneFlagSet(name, number) ); return query; }
And use it
var criteria = QueryOver.Of<InternalAssessor>() ... .WhereRestrictionOn(x => x.Name).IsLike(searchedName)
In order to fully fulfill your request, we need to enter some “person in the middle” object, which will contain a link to the query and our BitwiseRestrictions . Another extension will immediately accept it, add number and return a request. Does QueryOverRestrictionBuilder in NHibernate do the QueryOverRestrictionBuilder ... but doesn't work above and is simple enough?
source share