开发者

Nhibernate Where Condition

开发者 https://www.devze.com 2023-01-25 09:13 出处:网络
I want to generate a where condition in nHibernate Like Below Can any one Help me out Select Id,Name from

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

精彩评论

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