我有以下实体
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
的产品任何帮助将不胜感激
先谢谢
答案 0 :(得分:1)
就像你的other question已经回答:
var foobar = "foobar";
var result = Session.Linq<Product>()
.Where(product => product.Attributes
.Any(attr => attr.Value == foobar))
.List<Product>();