Nhibernate 将多值字段映射到IList<&燃气轮机;氟替尼酯
我有以下问题:Nhibernate 将多值字段映射到IList<&燃气轮机;氟替尼酯,nhibernate,fluent-nhibernate,Nhibernate,Fluent Nhibernate,我有以下问题: 我们在DB中有类似ProductLineIdList的多值字段,它存储每个允许的productLines,并用逗号分隔(例如“2,13,27,33”)。我想将此字段映射到IList(包含4个实体的列表)。有可能吗?Thx将产品线保存为字符串,然后使用未映射的属性返回产品线列表如何?我想你很难用纯正的NHibernate做到这一点 public class Product { // protected so we can't see this protected v
我们在DB中有类似ProductLineIdList的多值字段,它存储每个允许的productLines,并用逗号分隔(例如“2,13,27,33”)。我想将此字段映射到IList(包含4个实体的列表)。有可能吗?Thx将
产品线
保存为字符串,然后使用未映射的属性返回产品线列表如何?我想你很难用纯正的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>();
}
}
}
}
公共类产品
{
//受保护,所以我们看不到这个
受保护的虚拟字符串productLines{get;set;}
//指示NHibernate忽略此属性!
公共IList产品线
{
得到
{
如果(!string.IsNullOrEmpty(productLines))
{
return productLines.Split(',).ToList();
}
其他的
{
返回新列表();
}
}
}
}