I am new to automapper, so I'm not sure that this is possible.
I want to map a class, but ignoring those methods which are zero, I have an example of the code below. I get the following exception message when I run it.
An unrestricted exception of "AutoMapper.AutoMapperMappingException" type occurred in AutoMapper.dll
Unfortunately this interface is not an option to change, so I agree Am I possible to miss some sort of configuration?
public interface etting {string name {get; Set; } Zero IgnoreMe (); } Public Sector Foo: ITing {public string name {get; Set; } Public Zero IgnoreMe () {}} class program {static or oid main (string [] arg) {var fooSource = new Foo {name = "Bobby"}; Mapper Createmap & lt; ITing, Etting & gt; (); Var fooDestination = Mapper Map & lt; ITing & gt; (FooSource); Console.WriteLine (fooDestination.Name); Console.ReadLine (); If you are typing AutoMapper is dynamically an implementation (proxy) The type will make for you
However Proxy Generation supports only properties , so it does not even throw a descriptive exception for your
ignorance method, then you can enter your
Ignore can not ignore the method.
As an alternative solution, you can explicitly specify that
ConstructUsing overloads does not generate automation proxy in this case.
Mapper Createmap & lt; ITing, Etting & gt; (). Constructing (ResolutionContext c) => New Foo ());
Or unless you have a good reason, you can directly
Foo
Mapper. Crescent & lt; ITING, FU & gt; ();
No comments:
Post a Comment