Dan*_*ams 16 nhibernate queryover
我想模拟这个查询:
SELECT * FROM FOO WHERE ID IN (1,2,3)
Run Code Online (Sandbox Code Playgroud)
我怎么能在FNH这样做?
var ids = new List<int>{1,2,3};
var results = session.QueryOver<Foo>().Where( x=> ids.Contains(x.id) );
Run Code Online (Sandbox Code Playgroud)
但这不起作用,只是给了我一个"无法识别的方法调用"异常.
有任何想法吗?这必须是一个共同的要求.
Dan*_*ams 37
啊哈哈!AddRestrictions有一个IsIn方法:
var results = session.QueryOver<Foo>().AndRestrictionOn(x=>x.id).IsIn(ids)
Run Code Online (Sandbox Code Playgroud)
有了这最后一件,我们可能已经准备好抛弃我们多年的手工卷制ORM了!