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));
精彩评论