Я пытаюсь понять, почему эта конфигурация не отображает свойство Company
. Должно ли оно работать так, как описано здесь ?
public class CreateAccountViewModel
{
public string Name { get; set; }
public string VatNumber { get; set; }
public string Acronym { get; set; }
}
public class Account
{
public string Name { get; set; }
public string VatNumber { get; set; }
public Company Company { get; set; }
}
public class Company
{
public string Acronym { get; set; }
}
public class UnitTest
{
[Fact]
public void Foo()
{
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<CreateAccountViewModel, Account>();
cfg.CreateMap<CreateAccountViewModel, Company>();
});
config.AssertConfigurationIsValid();
}
}
Результат теста:
Message:
AutoMapper.AutoMapperConfigurationException :
Unmapped members were found. Review the types and members below.
Add a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type
For no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters
=====================================================================
CreateAccountViewModel -> Account (Destination member list)
Kairos.UnitTests.CreateAccountViewModel -> Kairos.UnitTests.Account (Destination member list)
Unmapped properties:
Company