Hi,
I have some issues with automapper.
I have two objects and I want to convert these.
First object;
public partial class WorkCommandDocuments
{
public int ID { get; set; }
[Required]
[StringLength(300)]
public string WorkCommandNumber { get; set; }
[Required]
[StringLength(500)]
public string WorkCommandDocumentDefinition { get; set; }
[Required]
public byte[] WorkCommandDocument { get; set; }
[Required]
[StringLength(100)]
public string FileExtension { get; set; }
public virtual WorkCommands WorkCommands { get; set; }
}
Second object;
public class WorkCommandDoc
{
[DataMember]
public int ID { get; set; }
[DataMember]
public string WorkCommandNumber { get; set; }
[DataMember]
public string WorkCommandDocumentDefinition { get; set; }
[DataMember]
public byte[] WorkCommandDocument { get; set; }
[DataMember]
public string FileExtension { get; set; }
public WorkCommandDoc(int id, string workCommandNumber, string workCommandDocumentDefinition, byte[] workCommandDoc, string fileExtension)
{
ID = id;
WorkCommandNumber = workCommandNumber;
WorkCommandDocumentDefinition = workCommandDocumentDefinition;
WorkCommandDocument = workCommandDoc;
FileExtension = fileExtension;
}
}
But I'm getting 'AutoMapper.AutoMapperConfigurationException' in AutoMapper.dll error.
EDIT: I solve this problem with adding default constractor to WorkCommandDoc object.
What I have tried:
I tried:
Mapper.Initialize(config =>
{
config.CreateMap<WorkCommandDocuments, WorkCommandDoc>();
});
Mapper.AssertConfigurationIsValid();
WorkCommandDoc wc = Mapper.Map<WorkCommandDoc>(doc);