简体   繁体   中英

How to translate this simple SQL query to NHibernate?


I wonder how to translate this sql query to use the Criteria API. If not possible or not easy, HQL would be OK

SELECT * FROM Table1 WHERE Field1 in (1,2,3,4,5,6)

(1,2,3,4,5,6) is an external dynamic array that I set to the query as parameter, it's not a constant.

ICriteria criteria = Session.CreateCriteria();
criteria.Add(Expression.In("Field1", myArray)); //where myArray is the dynamic array you say
criteria.List();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM