c# - Saving related entities with a repository in a disconnected application -


we starting develop disconnected application , 1 problem comes again again repositories , aggregates. use ef.

one example brands , manufacturers, have m:n relationship. 1 manufacturer can have 1 or more brands.

the ibrandrepository<brand> contain crud methods brands.

so if edit brand, load manufacturers assigned brand. object graph mapped view model contains brand's properties , list<manufacturer> of manufacturers.

the question is, best approach when saving brand using repository? manufacturers assigned brand may deleted, other manufacturer may have been added.

1. logic best placed in ibrandrepository? if so, 1 query database before saving brand decide each manufacturer if added, edited, or deleted.

2. should there separate repository ibrandmanufacturerrepository, concerned assign brand manufacturer?

as aggregate root, save brand , assigned manufacturers using ibrandrepository -- call savechanges() make sure happens in 1 database transaction. if there 2 repositories involved, or additional domain service, no longer transaction.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -