nHibernate中的继承

时间:2010-09-26 15:38:43

标签: nhibernate inheritance

我有以下实体

public abstract class ProductAttribute
{
    public virtual long Id { get; private set; }
    public virtual string Name { get; set; }
}

public class TextAttribute : ProductAttribute
{
   public virtual string Value { get; set; }
}

and 

public class Product
{        
    public virtual long Id { get; private set; }
    public virtual IList<ProductAttribute> Attributes { get; private set; }
}

我现在要做的是获取具有TextAttribute且value = myValue

的产品

任何帮助将不胜感激

先谢谢

1 个答案:

答案 0 :(得分:1)

就像你的other question已经回答:

var foobar = "foobar";
var result = Session.Linq<Product>()
                    .Where(product => product.Attributes
                                             .Any(attr => attr.Value == foobar))
                    .List<Product>();