Error when using AutoMapper to map from a POCO to an NHibernate proxy object
We recently upgraded AutoMapper and ran into an issue when mapping items a certain way.
When I load an NHibernate domain object, and attempt to map my model to it in the following manner:
var myPoco = new MyPoco();
var proxy = repository.Load<MyDomainObject>(id);
Mapper.Map(myPoco, proxy);
I get the following error:
Missing type map configuration or unsupported mapping.
MyPoco-> MyDomainObjectProxy
However, if I use the following overload of the method, I do not get the exception:
var myDomainObj = Mapper.Map<MyPoco, MyDomainObject>(myPoco);
When you look into the AutoMapper code, you can see that these methods call different base methods in the code base, which is why they behave differently.
Is this a bug with the newer version of AutoMapper, or is there another way of using the Mapper.Map(source, destination) method with proxies?
Note : this is using AutoMapper 2.2.0. I believe this worked fine in 0.3.
This is a known issue, fixed the develop branch. Check out the prerelease version here:
AutoMapper 2.2.1-ci8
The fix will be released shortly in the 2.2.1 version.
链接地址: http://www.djcxy.com/p/37370.html上一篇: AutoMapper在映射列表时忽略属性