nHibernate 用于选择具有空子集合的所有实体的标准
我很难编写一个标准来选择具有空子集合或空孙集合的所有实体。我可以将这些作为单独的标准来执行,但我无法将其合并为单个标准。
类结构:
public class Component
{
public IList<Version> Versions { get; set; }
}
public class Version
{
public IList<SubscribeEvent> SubscribedEvents { get; set; }
public IList<PublishEvent> PublishedEvent { get; set; }
}
这不起作用:
return session
.CreateCriteria<Component>("c")
.CreateCriteria("Versions", "v")
.Add(Restrictions.Or(Restrictions.IsEmpty("c.Versions"), Restrictions.And(Restrictions.IsEmpty("v.PublishedEvents"),
Restrictions.IsEmpty("v.SubscribedEvents"))))
.SetCacheable(true);
I'm having difficulty writing a Criteria to select all entities with empty child collections or empty grand-child collections. I can do these as separate Criteria but I'm having trouble combining into a single Criteria.
class structure:
public class Component
{
public IList<Version> Versions { get; set; }
}
public class Version
{
public IList<SubscribeEvent> SubscribedEvents { get; set; }
public IList<PublishEvent> PublishedEvent { get; set; }
}
This does not work:
return session
.CreateCriteria<Component>("c")
.CreateCriteria("Versions", "v")
.Add(Restrictions.Or(Restrictions.IsEmpty("c.Versions"), Restrictions.And(Restrictions.IsEmpty("v.PublishedEvents"),
Restrictions.IsEmpty("v.SubscribedEvents"))))
.SetCacheable(true);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经设法找到了一个解决方案,不确定它是否是最好的(我应该购买 NH 分析器)
I've managed to work out a solution, not sure if it is the best (I should buy NH profiler)