Nhibernet 选择计数
我有两个实体
A:
public class Product
{
public virtual int ID { get; set; }
public virtual IList<Picture> Pictures { get;set;}
}
B:
public class Picture
{
public virtual int ID { get;set;}
public virtual Product { get;set;}
public virtual Path { get;set;}
}
我如何使用 NHibernate ICriteria 选择一个仅包含图片计数大于 0 的产品的
列表
I have two entity
A:
public class Product
{
public virtual int ID { get; set; }
public virtual IList<Picture> Pictures { get;set;}
}
B:
public class Picture
{
public virtual int ID { get;set;}
public virtual Product { get;set;}
public virtual Path { get;set;}
}
How do i using NHibernate ICriteria select a list containing only products with a picture count larger than 0
regards keld
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你需要一些精确的图片值,你可以使用这个:
如果你不需要空集合,那么你可以使用 IsNotEmpty 限制
If you need some exact value of pictures you can use this:
If you just need not empty collection then you can use IsNotEmpty restriction
您不需要为此使用条件查询。您可以使用简单的 Linq 来完成此操作,
请注意其中使用 Any ,这比执行 count > > 更快。 0.
抱歉,我有点忘记你是从 dB 中检索它。在这种情况下,您需要执行以下操作。
you dint need to use a criteria query for this. You can do it using simple Linq
Note the use of Any inside there which is faster than doing a count > 0.
Sorry I kinda forgot you are retrieving it from the dB. Here is what you need to do in that case.