I remember trying this before and i gave up, but now i want to try to get it working.
In my ObjectFactoryBase class i want to support automatic mapping from BO to DTO and visa versa all based on a mappingdefinition. That'll work for sure as long the developers from my company do write the mapping once foreach business object.
Csla offers a nice DataMapper static helper class which i wanted to use, it seems like it does dynamic stuff so reflection is just once and then dynamic in memory with IL stuff. Oke.
Using DataMap.Load won't do because that does a ReadProperty on each managed property, even if they are LazyLoaded.
My code:
DataMap dm = new DataMap(BOType, DTOType);results into an exception
"AccessViolationException was unhandled"
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
happens at DataMapper line 268
object value = mapping.FromMemberHandle.DynamicMemberGet(source);Nevermind, i figured it out.
Using the DataMap class isn't needed when Mapping by an Dictionary.
Giving a 3rd parameter caused another overloaded method to be called, with object as parameter. Well it isn't giving an correct exception, but that's all.
All i needed to do:
private Dictionary<string, object> GetDictionary(BO obj, List<IPropertyPart> properties, bool isInserting)...
Copyright (c) Marimer LLC