I would create a QueryOver like this
SELECT * FROM Table WHERE Field IN (1,2,3,4,5)
I've tried with Contains
method but I've encountered the Exception
"System.Exception: Unrecognised method call: System.String:Boolean Contains(System.String)"
Here my code
var qOver = _HibSession.QueryOver<MyModel>(() => baseModel) .JoinAlias(() => baseModel.Submodels, () => subModels) .Where(() => subModels.ID.Contains(IDsSubModels)) .List<MyModel>();
Let's have a look into a simple example of the Native SQL queries in NHibernate. The above example uses CreateSQLQuery() to get back a list of objects, and you will also notice that the root entity type you want the query to return is specified as Customer.
QueryOver is a strongly-typed version of Criteria, and is more NHibernate specific. Pretty much anything you can do in ICriteria can be done with QueryOver.
List<object[]> olist = null; olist = (_session. CreateQuery("Select pc.Id as Id, " + "pct. DescEn as DescEn,pct. DescAr as DescAr, pc.
The "projection" is kind of like plucking out what data you will need so that NHibernate only asks the database for just that data when it makes the SQL.
I've found the solution!! :-)
var qOver = _HibSession.QueryOver<MyModel>(() => baseModel) .JoinAlias(() => baseModel.Submodels, () => subModels) .WhereRestrictionOn(() => subModels.ID).IsIn(IDsSubModels) .List<MyModel>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With