Comments (3)
UnitOfWork works with all or nothing logic.
Managing transactions is one method. However, no update or add method will be committed to the database without savechange running.
Users have to call UnitOfWork.Repository.Complete method because savechanges will not work without the Complete method in scope.
Supports EF Core Change Tracker feature. Tries to apply all changes to the context. If he gets an error on any of them, he can't perform any action anyway.
from easyrepository.efcore.
I respect that this is closed, and your explanation makes sense.
I am curious as to why Microsoft has a TransactionScope
and a Rollback
ability in this case?
I think this is more of an EfCore question, if you have time can you help me understand why this is the case?
For Example:
https://stackoverflow.com/questions/53324601/transaction-scope-for-different-repository-classes
public PizzaService(IDbContextScopeFactory contextScopeFactory, IPizzaRepo pizzaRepo, IPizzaIngredientsRepo ingredientRepo)
{
_contextScopeFactory = contextScopeFactory;
_pizzaRepo = pizzaRepo;
_ingredientRepo = ingredientRepo;
}
public async Task SavePizza(PizzaViewModel pizza)
{
using (var contextScope = _contextScopeFactory.Create())
{
int pizzaRows = await _pizzaRepo.AddEntityAsync(pizza.Pizza);
int ingredientRows = await _ingredientRepo.PutIngredientsOnPizza(
pizza.Pizza.PizzaId,
pizza.Ingredients.Select(x => x.IngredientId).ToArray());
contextScope.SaveChanges();
}
}
What is the advantage of the TransactionScope
if its truly an 'all or nothing' logic?
from easyrepository.efcore.
This resource will be useful to you. @jeffward01
https://stackoverflow.com/questions/50844828/ef-db-savechanges-vs-dbtransaction-commit
from easyrepository.efcore.
Related Issues (15)
- ✨[FEATURE] Implement Abstractions Layer
- ✨ [FEATURE] Unit Of Work
- ✨ [FEATURE] Specification pattern must be supported (Ardalis.Specification)
- 📌 [CUSTOM] Upgrade target framework from dotnet5 to dotnet6
- ✨ [FEATURE] Add 'Enum.AsNoTracking' to all methods instead of using bool values HOT 4
- ✨ [FEATURE] Would like to migrate to 'file scoped' namespaces HOT 2
- ✨ [FEATURE[ Introduce IAsyncEnumerable methods or remove IEnumerable<> as a parameter and change to ICollection<>
- ✨ [FEATURE] Pagination / filtering re-implementation HOT 7
- ✨ [FEATURE] Enable Nullable Reference Types, add null exceptions, add null checks HOT 2
- ✨ [FEATURE] Bulk Delete and Bulk Update with EF.Core 7
- ✨[FEATURE] Implement Add And AddRange operations on generic repository of interface layer
- ✨ [FEATURE] Implement delete operations for generic repository on interface layer
- ✨ [FEATURE] Implement Update Operations for Abstraction Layer
- ✨[FEATURE] Implement Get endpoints for abstraction layer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easyrepository.efcore.