Right now I'm using the Criteria API and loving it, but it would be even better if I could make the switch to the QueryOver API. However, my setup is a little strange. In order to partition data into tables, I have one base abstract class:
Listing
and a number of classes which inherit from that:
Listing_UK
Listing_US
etc.
With the criteria API, I can do something like:
Type t = typeof(Listing_UK);
if (condition) t = typeof(Listing_US);
DbSession.CreateCriteria(t)
.Add(Restriction.Eq("field",value)
.List<Listing>());
Basically, using the same query on different classes. It seems like the strongly-typed nature of QueryOver prevents me from doing this- the basic problem being that:
DBSession.QueryOver<Listing_UK>()
doesn't cast to
DBSession.QueryOver<Listing>
While I understand why, I'm wondering if anyone has any trick I could use to create a generic QueryOver that will still target the right table?
You might find you could use the following overload: