Hi,
We have a product entity which has a collection with specifications like this:
[Table("Masterdata.Products")]
public class Product : FullAuditedEntity, IMustHaveTenant
{
public int TenantId { get; set; }
[Required]
public string Code { get; set; }
public ICollection<ProductSpecificationValue> Specifications { get; set; }
}
We want to update the product trough following DTO:
public class ProductCreateOrEditDto : EntityDto<int?>
{
[Required]
public string Code { get; set; }
public ICollection<ProductSpecificationValueCreateOrEditDto> Specifications { get; set; }
}
Following code we want to use to update the product:
public async Task Update(ProductCreateOrEditDto input)
{
var product = await _productRepository.GetAllIncluding(e => e.Specifications).Where(e => e.Id == input.Id).FirstOrDefaultAsync();
ObjectMapper.Map(input, product);
}
We can't update the values in the specification as the objectmapper won't sync the collection. The collection in the product gets deleted and AutoMapper creates new instances for the specification in the input object. Referring to following github topic i would assume that Automapper would sync the collections based on the EF properties. https://github.com/aspnetboilerplate/aspnetboilerplate/pull/4034
Do we need to add some configuration to make this work? Are we missing something else?
Ok, maybe you can explain the solution so it can be useful for other people.
Hi, do you still having this problem? When i visit dev.takldit.com, i get a working login screen.