-
Notifications
You must be signed in to change notification settings - Fork 342
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
SaveChangesAsync(bool ensureAutoHistory = false, params IUnitOfWork[] unitOfWorks)这个怎么使用 #122
Comments
什么应用程序?web还是wpf?如果是web的话,默认每个就是Request Scope的呀 |
是web,我有2个上下文对象是不同数据库的,例如: |
//add UnitOfWork |
数据库是不同机器还是相同机器上的? |
是不同机器上的mysql数据库,我查了相关资料是因为使用了 await 的问题,需要如下使用: using(var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) 加上这个测试之后发现 还是报错,错误如下: 也就是说在.net core 里面已经不能使用TransactionScope 作为分布式事务的解决方案。 /// Saves all changes made in this context to the database with distributed transaction. /// /// True if save changes ensure auto record the change history. /// An optional array. /// A that represents the asynchronous save operation. The task result contains the number of state entities written to database. public async Task SaveChangesAsync(bool ensureAutoHistory = false, params IUnitOfWork[] unitOfWorks) { using (var ts = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { var count = 0; foreach (var unitOfWork in unitOfWorks) { count += await unitOfWork.SaveChangesAsync(ensureAutoHistory); }
|
目前框架就不支持分布式事务了 |
应该就是这个原因了,我已经几年没有写C#了,囧 |
现在搞java了? |
我有个想法 想把查询表达式的条件封装类集成进来 达到可以根据自己组装条件的效果,例如: |
你可以提交一个PR,我看一下 |
后续 我抽时间去弄,因为 我已经在我的项目里面用了,提交了我在告诉你。 |
所以这个问题不解决了吗?现在代码还是没变,但 .net core 已经到 5.0 了,现在还在报错: A TransactionScope must be disposed on the same thread that it was created. |
这个分布式事务,在core里面已经不能使用了。我是下载的源代码去掉了。 |
SaveChangesAsync(bool ensureAutoHistory = false, params IUnitOfWork[] unitOfWorks)
这个怎么使用?
我这边直接传IIUnitOfWork 报错:
TransactionScope必须在同一创建线程上
The text was updated successfully, but these errors were encountered: