Closed coskuncinar closed 7 years ago
I would add it to UnitOfWorkBase : https://github.com/digipolisantwerp/dataaccess_aspnetcore/src/Digipolis.DataAccess/Uow/UnitOfWorkBase.cs
this is not enough if you say "SaveChangesAsync' , i need start begintran when i insert /update first record ,think "begin tran commit " as in Tsql ( you need thought to take document last number in DocumentNumberTablo and update last+1 document number in same DocumentNumberTablo)
Will you add this feature? or How can I add you? can you help me??
"I'm sorry my english"
The SaveChanges methods are transactional. If you prepare all your changes on the DbContext and then call SaveChanges, all changes will be applied in 1 transaction.
If you want to manage the transactions yourself, you can add BeginTransaction, RollBack and Commit methods on UnitOfWorkBase and expose the corresponding methods of the _context.Database object.
yeap , I want to manage the transactions myself. But The SaveChanges is last step. think like that begin tran go declare @DocNum select @DocNum=DocumentNumber from DocumentNumbers DocumentType =xx ---> when i take lastdocumentnumber, nobody can take DocumentNumber in same time . other client should wait . insert into importsTable(DocNum,xx,xxx,xxx) values (@DocNum,yyy,yy,yyy) //other code, insert update and such update s set s.DocumentNumber=@DocNum+1 from DocumentNumbers DocumentType =xx go commit or rollback go when its done , other client can connect to this "DocumentNumbers" table thats why I must manage my process
I hope I can express myself...
Then I would make a custom repository, handle the whole transaction in there and not use the generic UnitOfWork and repositories.
Can you give an example how to use transaction?
Thank you.
@anhlee24 , you can find more info on transactions with EF Core here : https://docs.microsoft.com/en-us/ef/core/saving/transactions.
Thank you!
i do not know that they can use together.
I am working to add new feature to UOW, but your framework is a bit complicated. Where should I add Begintransaction and Commit And Rollback. Thank you for responding..