开发者

Nhibernate Where Condition

I want to generate a where condition in nHibernate Like Below Can any one Help me out

Select Id,Name from Employee where (id=@id or Id is Null) i want the code to generate 开发者_如何学Gothe where condition.


You should check out the documentation here: http://nhibernate.info/doc/nh/en/index.html#querycriteria-narrowing

A solution using the criteria API is:

session.CreateCriteria<Employee>()
    .Add(Restrictions.Eq("Id", id) | Restrictions.IsNull(id));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜