Note that there are some explanatory texts on larger screens.

plurals
  1. POAutomapper does not ignore 2nd level nested property when asked to
    primarykey
    data
    text
    <p>Having some trouble with the Automapper 'Ignore' option. Here is a test outlining the issue I'm having:</p> <pre><code> using AutoMapper; using NUnit.Framework; [TestFixture] public class Sample { public class OuterSource { public InnerSource Inner { get; set; } } public class InnerSource { public InnerInnerSource InnerInner { get; set; } } public class InnerInnerSource { public int Value { get; set; } } public class OuterDest { public InnerDest Inner { get; set; } } public class InnerDest { public InnerInnerDest InnerInner { get; set; } } public class InnerInnerDest { public int Value { get; set; } } [Test] public void MergeMap_WhenIgnoringLevel2InnerProperty_PropertyRemainsUnchanged() { Mapper.CreateMap&lt;OuterSource, OuterDest&gt;(); //.ForMember(d =&gt; d.Inner, opts =&gt; opts.Ignore()); // test passes when added back in Mapper.CreateMap&lt;InnerSource, InnerDest&gt;() .ForMember(d =&gt; d.InnerInner, opts =&gt; opts.Ignore()); var source = new OuterSource { Inner = new InnerSource { InnerInner = new InnerInnerSource { Value = 25 } } }; var destination = new OuterDest { Inner = new InnerDest { InnerInner = new InnerInnerDest { Value = 99 } } }; Mapper.Map(source, destination); Assert.That(99 == destination.Inner.InnerInner.Value); // FAIL - destination.Inner.InnerInner is null } } </code></pre> <p>It appears that the 'ignore' option is not fully working. If I comment back in the 1st 'ignore' then everything works as expected. The issue is that there are a number of other properties on the Inner class that I need mapped. The only one to ignore is the InnerInner class.</p> <p>Any ideas? The same issue, I think, was outlined <a href="https://stackoverflow.com/questions/7188952/automapper-doesnt-ignore-nested-types">here</a> but the accepted answer does not work for me.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload