-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why add methods on RepositoryBaseOfT contain SaveChanges #266
Comments
The repository pattern is meant to make access to persistence resemble an in-memory collection with more advanced querying capabilities. When you add an item to a |
Thank you @ardalis for your replay |
It's up to you how you want to design it. For most systems, especially web APIs that are only doing one operation at a time, typically, having each repo operation save as part of it works fine. For others, you'll want a separate unit of work and/or transaction pattern to wrap around several operations. There's an issue discussing exactly this here: Do what works for your needs. |
Why the framwork don't give the free to developer to save chanes or not , may be i need to write multiple add then call save changed.
_repositroy.AddAsync(tenant1 );
_repositroy.AddAsync(tenant2);
_repositroy.SaveChanges();
I you remove SaveChanged method from Add method i can write the example without need to use even unit of work or begin transation
The text was updated successfully, but these errors were encountered: