开发者

Inheritance in nHibernate

开发者 https://www.devze.com 2023-01-17 10:51 出处:网络
I have the following entities public abstract class ProductAttribute { public virtual long Id { get; private set; }

I have the following entities

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 vir开发者_运维知识库tual IList<ProductAttribute> Attributes { get; private set; }
}

what I want to do now is to get the product that has TextAttribute with value = myValue

Any help will be appreciated

Thanks in Advance


Just like your other question was answered:

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

精彩评论

暂无评论...
验证码 换一张
取 消