I'm using some models inside my domain which are not very serialization- or mapping-friendly, such as structs or classes from the System.Net.*
namespace.
Now I'm wondering if it's possible to define custom type mappings in Entity Framework.
Pseudo:
public class PhysicalAddressMap : ComplexType<PhysicalAddress>() {
public PhysicalAddressMap() {
this.Map(x => new { x.ToString(":") });
this.From(x => PhysicalAddress.Parse(x));
}
}
Desired result:
SomeEntityId SomeProp PhysicalAddress SomeProp
------------------------------------------------------------------
4 blubb 00:00:00:C0:FF:EE blah
^
|
// PhysicalAddress got mapped as "string"
// and will be retrieved by
// PhysicalAddress.Parse(string value)