Ich verwende Enterprise Library.Ich möchte die Spalte (des Integer-Typs) zu Enum Type zuordnen.C# Lambda Expression Mapping mehrere Bedingungen
Say
Enum BloodGroup Type
{
OPositive,
ONegative,
ABPositive,
ABNegative,
BPositive,
BNegative,
NotSet
}
Ich Mapping-Datenbank Tabelle der Spalte auf C# Typen der (Klasse Employee) Eigenschaften.
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 funktioniert gut, aber ich möchte mehrere Zustand von Enum in WithFun
Erweiterung zur Karte Method.I bedeutet so etwas wie
.WithFun(rec=> rec.IsDBNull(rec.GetOrdinal("BloodGroup")) ? BloodGroup.NotSet
rec.GetOrdinal("BloodGroup")==1 ?BloodGroup.OPositive
rec.GetOrdinal("BloodGroup")==2 ?BloodGroup.ONegative
)
Helfen Sie mir mehrere Zustand zu überprüfen?
Ist es NHibernate ??? – Aliostad
Nein Enterprise Library 5.0 – IExtensible