views:

33

answers:

1

Hello All,

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 virtual 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

+1  A: 

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>();
Rafael Belliard
I'm missing the NHibernate.Linq.dll file so could you please send it to me ?
Amira Elsayed
Here you go --> http://sourceforge.net/projects/nhibernate/files/NHibernate/2.1.2GA/NHibernate.Linq-2.1.2-GA-Bin.zip/download
Rafael Belliard
I have downloaded the dll , and try to use the code , but it didn't work with me because Attribute does not have Value property , the Attribute of Type ProductAttribute and the value property is in the TextAttribute class that inherit from ProductAttribute abstract class
Amira Elsayed