Many to many relationship - How to delete/modify nested collection items? #394
scarybook
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I created many to many relationship and had a problem.
When I created new entity with collection of items it worked fine - items were added, but when I tried to update this entity with new set of items I was getting an error (only when any item of collection was already in DB) .
Sample model classes:
AddEditProductCommand class
I needed to change getting an object from DB as below:
var product = await _unitOfWork.Repository<Product>().Entities.Include(x => x.Categories).FirstOrDefaultAsync(x => x.Id == command.Id);
Beta Was this translation helpful? Give feedback.
All reactions