- What is your product version? 10.2.0
- What is your product type? Angular
- What is product framework type? .net core
I have a parent entity with a list of child objects. On the UI I load up the parent screen with a list of child objects. I edit one of the child objects attributes. I call createOrUpdate on the parent object and pass everything correctly to the API.
I call parentRepository.GetAllIncluding(x=>x.children).FirstOrDefault( s=>s.Id == input.Id.Value);
I also call:
ObjectMapper.Map(input, parentObject); var children = new List<LinkedChildren>(); ObjectMapper.Map(input.Children, children); parentObject.Children = children; await parentRepository.UpdateAsync(parentObject);
The Parent entity has public virtual List<LinkedChildren> Children { get; set; }
The Child entity has
[Table("Children")] public class Children : FullAuditedEntity<Guid> { [Required] public virtual int ParentId { get; set; } [ForeignKey("ParentId")] public virtual Parent Parent { get; set; }
I can create the children however when I save after that the children become IsDeleted = 1
2 Answer(s)
-
0
Hi,
To work with such object graphs, it is better to use https://github.com/zzzprojects/GraphDiff. We already have an integraion package, so you can add it to your project and use it https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.EntityFramework.GraphDiff/
-
0
I resolved the problem by creating a method to add/update/remove the list of items manually. GraphDiff looks interesting.