伙计们! 我正在尝试对我的实体进行深度搜索。这就是想法:通过示例使用实体查找一些记录。 NHibernate 为我们提供了 ID 搜索。
Entity entity = Session.Get<Entity>(id);
但我需要验证某些实体是否存在,即使 ID 为空。像这样的东西:
Entity search = new Entity("Full name from some record");
Entity entity = Session.Get<Entity>(search);
if (entity == null) {
Console.WriteLine("This record don't exists.");
}
else {
Console.WriteLine("This record exists!");
}
我想在数据库中搜索一些实体并返回一个 bool 值。如果记录存在则为 TRUE,否则为 FALSE。有这样的事情已经完成了吗?如果不这样做,您知道如何实现这种情况吗? 谢谢!!
最佳答案
关于c# - 按属性值创建实体搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14040081/