views:

17

answers:

1

Hi,

I have following problem:

We have multi-value fields in DB like ProductLineIdList which stores every allowed productLines separated by comma (for example "2,13,27,33"). I would like to map this field to IList (list with 4 entities). Is it possible to do that? Thx

+1  A: 

How about saving the productLines as a string, and then use a non mapped property to return the list of product lines? I suspect you'd have a hard time pulling that off with pure NHibernate.

public class Product
{
    // protected so we can't see this
    protected virtual string productLines { get; set; } 

    // instruct NHibernate to ignore this property!
    public IList<string> ProductLines 
    { 
        get 
        { 
            if (!string.IsNullOrEmpty(productLines))
            {
                return productLines.Split(',').ToList();
            }
            else
            {
                return new List<string>();
            }
        }
    }
}
Rafael Belliard