我正在使用Enterprise Library.I想要将整列类型的列映射到枚举类型。C#Lambda表达式映射多个条件
说
Enum BloodGroup Type
{
OPositive,
ONegative,
ABPositive,
ABNegative,
BPositive,
BNegative,
NotSet
}
我映射数据库表的列C#类型的(Employee类)属性。
IRowMapper<Employee> addressMapper = MapBuilder<Employee>
.MapAllProperties() // map all properties
.Map(p=>p.BloodGroup) // override BloodGroup property
.WithFunc(rec => rec.IsDBNull(rec.GetOrdinal("BloodGroup"))
? BloodGroup.NotSet
: BloodGroup.OPositive)
.Build();
代码工作正常,但我要地图的枚举WithFun
延伸的多个条件Method.I的意思是这样
.WithFun(rec=> rec.IsDBNull(rec.GetOrdinal("BloodGroup")) ? BloodGroup.NotSet
rec.GetOrdinal("BloodGroup")==1 ?BloodGroup.OPositive
rec.GetOrdinal("BloodGroup")==2 ?BloodGroup.ONegative
)
帮我检查多重条件?
是NHibernate吗? – Aliostad 2010-10-21 20:30:52
没有企业库5.0 – IExtensible 2010-10-21 20:32:56