Just want to post an update for anyone stumbling across this thread...
For the MapTo extension method to work on an entity where you want to MapTo an Object of the same type, you still need to decorate the class with the AutoMap annotation:
[AutoMap(typeof(MyObject))]
public class MyObject: FullAuditedEntity, IMustHaveTenant
{
}
Thanx a stack!
I will give that a try :)
Regards, Corne du Plooy
HI hikalkan,
Thank you for the reply.
I have created a sample that shows how the error is generated (Not using a Domain Service but only an Application service)
public class TestAppService : ITestAppService
{
private IRepository<CostAccount> _costAccountRepository;
public TestAppService(IRepository<CostAccount> costAccountRepository)
{
_costAccountRepository = costAccountRepository;
}
[UnitOfWork]
public virtual async Task<bool> UpdateTest(List<CostAccountDto> values)
{
foreach (CostAccountDto I in values)
{
await UpdateTest(I);
}
return true;
}
[UnitOfWork]
public virtual async Task<bool> UpdateTest(CostAccountDto value)
{
//Get list of stored Cost Accounts
List<CostAccount> storedCostAccounts = await _costAccountRepository.GetAllListAsync();//This is required for business rules validation which has been excluded for simplicity.
await _costAccountRepository.UpdateAsync(value.MapTo<CostAccount>());
return true;
}
}
The EF error only occurs when I retrieve all the stored objects before calling the update method on the repository.
Regards, Corne du Plooy