I am using Enterprise Library.I want to map the column (of integer type) to Enum Type.
Say
Enum BloodGroup Type
{
OPositive,
ONegative,
ABPositive,
ABNegative,
BPositive,
BNegative,
NotSet
}
I am mapping Database Table's column to C# Types's (Class Employee) Properties.
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();
Code working fine but i want to map multiple condition of Enum in WithFun
extension Method.I mean something like
.WithFun(rec=> rec.IsDBNull(rec.GetOrdinal("BloodGroup")) ? BloodGroup.NotSet
rec.GetOrdinal("BloodGroup")==1 ?BloodGroup.OPositive
rec.GetOrdinal("BloodGroup")==2 ?BloodGroup.ONegative
)
Help me to check multiple condition?