2011-08-29 51 views

回答

3

隨着QueryOver接口:

session.QueryOver<MappedType>().AndRestrictionOn(m => m.tableid).IsIn(new int[] { 1, 2 , 3 , 4 }).List(); 

session.QueryOver<MappedType>().Where(m=> m.tableid.IsIn(new int[] { 1, 2 , 3 , 4 })).List(); 

或與標準接口:

session.CreateCriteria<MappedType>().Add(Expression.In("tableId", new int[] { 1, 2, 3, 4 })).List<MappedType>(); 
3

是它,即:

ISession session = GetSession(); 
var criteria = session.CreateCriteria(typeof(Product)); 

var ids= new[] {1,2,3}; 
criteria.Add(new InExpression("Id", ids)); 

var products = criteria.List<Product>(); 
4

簡單:

CurrentSession 
    .CreateCriteria(typeof(MappedType)) 
    .Add(Expression.In("MappedType.MappedId", new int[] { 1, 2, 3, 4 }));