Is it possible to extend QueryOver API by somehow? What I want to add is the fol
var criteria = QueryOver.Of<InternalAssessor>()
.WhereRestrictionOn(x => x.Sector).HasAtLeastOneFlagSet((int)sector)
Where sector is bit flag enum. We had such criterion for ICriteria API and I can do
.Where(BitwiseRestrictions.AtLeastOneFlagSet("Sector", (int)sector))
But want to have strongly typed way of doing it. Are there any examples of extending QueryOver?
There is, pretty straightforward way, how to take
IQueryOver
, search its Underlying criteria and append one, see https://gist.github.com/2304623And use it
To fulfil your request completely, we would need to introduce some man-in-the-middle object, which will hold reference to
query
and ourBitwiseRestrictions
. Another extension will immediately take it, appendnumber
and return query. Similar is doing theQueryOverRestrictionBuilder
in NHibernate... but is not the above working and simple enough?