Note that there are some explanatory texts on larger screens.

plurals
  1. POAutomapper failing to map on IEnumerable
    primarykey
    data
    text
    <p>I have two classes like so:</p> <pre><code>public class SentEmailAttachment : ISentEmailAttachment { public SentEmailAttachment(); public string FileName { get; set; } public string ID { get; set; } public string SentEmailID { get; set; } public string StorageService { get; set; } public string StorageServiceFileID { get; set; } } </code></pre> <p>And</p> <pre><code>public class SentEmailAttachmentItem : ISentEmailAttachment { [ItemName] public string ID { get; set; } public string SentEmailID { get; set; } public string FileName { get; set; } public string StorageService { get; set; } public string StorageServiceFileID { get; set; } } </code></pre> <p>Identical, as you can see (they both implement interface to ensure this)</p> <p>I then have the following mapping:</p> <pre><code>Mapper.CreateMap&lt;IEnumerable&lt;SentEmailAttachmentItem&gt;, IEnumerable&lt;SentEmailAttachment&gt;&gt;(); Mapper.CreateMap&lt;IEnumerable&lt;SentEmailAttachment&gt;, IEnumerable&lt;SentEmailAttachmentItem&gt;&gt;(); </code></pre> <p>I then have the following Unit test:</p> <pre><code>//create a load of sent email attachments var listOfSentEmailAttachments = new List&lt;SentEmailAttachment&gt;(); for (int i = 0; i &lt; 10; i++) listOfSentEmailAttachments.Add(new SentEmailAttachment { FileName = "testFileName", ID = Guid.NewGuid().ToString(), SentEmailID = Guid.NewGuid().ToString(), StorageService = "S3", StorageServiceFileID = "SomeFileID" }); var sentEmailAttachmentItems = Mapper.DynamicMap&lt;IEnumerable&lt;SentEmailAttachment&gt;, IEnumerable&lt;SentEmailAttachmentItem&gt;&gt;(listOfSentEmailAttachments); var itemToTest = sentEmailAttachmentItems.First(); Assert.IsInstanceOfType(itemToTest, typeof(SentEmailAttachmentItem)); </code></pre> <p>This fails - The IEnumerable sentEmailAttachmentItems is empty. It didn't map the list of SentEmailAttachments to it...</p> <p>Any idea what's going on??</p> <p>I have it working on single objects (mapping one of each to one of each) but not a collection...</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