Reputation: 203
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 the where condition.
Upvotes: 1
Views: 1961
Reputation: 17724
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));
Upvotes: 5