我想在 nHibernate 中生成一个 where 条件,如下所示有人可以帮我吗
选择 Id,Name from Employee where (id=@id or Id is Null) 我希望代码生成 where 条件。
您应该在此处查看文档:http : //nhibernate.info/doc/nh/en/index.html#querycriteria-narrowing
使用标准 API 的解决方案是:
session.CreateCriteria<Employee>()
.Add(Restrictions.Eq("Id", id) | Restrictions.IsNull(id));
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1936 次 |
最近记录: |