Tengo dos clases de este modo:AutoMapper no poder crear un mapa sobre IEnumerable
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; }
}
Y
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; }
}
idénticos, como se puede ver (ambos implementar la interfaz para asegurar esto)
Luego tengo la siguiente asignación:
Mapper.CreateMap<IEnumerable<SentEmailAttachmentItem>, IEnumerable<SentEmailAttachment>>();
Mapper.CreateMap<IEnumerable<SentEmailAttachment>, IEnumerable<SentEmailAttachmentItem>>();
que luego tienen la siguiente prueba Unidad:
//create a load of sent email attachments
var listOfSentEmailAttachments = new List<SentEmailAttachment>();
for (int i = 0; i < 10; i++)
listOfSentEmailAttachments.Add(new SentEmailAttachment { FileName = "testFileName", ID = Guid.NewGuid().ToString(), SentEmailID = Guid.NewGuid().ToString(), StorageService = "S3", StorageServiceFileID = "SomeFileID" });
var sentEmailAttachmentItems = Mapper.DynamicMap<IEnumerable<SentEmailAttachment>, IEnumerable<SentEmailAttachmentItem>>(listOfSentEmailAttachments);
var itemToTest = sentEmailAttachmentItems.First();
Assert.IsInstanceOfType(itemToTest, typeof(SentEmailAttachmentItem));
Esta falla - El IEnumerable sentEmailAttachmentItems está vacía. No correlacionó la lista de SentEmailAttachments con ella ...
¿Alguna idea de lo que está pasando ??
lo tengo trabajando en objetos individuales (uno de cada uno de mapeo a uno de cada uno), pero no una colección ...