osharp3使用经验:整合DbContextScope 文章 1

osharp3的事务处理是跳过savechangeing方法来控制的,没有DbContextScope专业

DbContextScope管理dbcontext的优劣本文不讨论

整合过程:

1、在.Data.Entity/Extensions/ServiceCollectionExtensions.cs

注入1DbContextScopeFactory 与 IAmbientDbContextLocator,

并且去掉却来的IUnitOfWork注入,

就是把dbContext完全交DbContextScope管理

如图

image

二、改造Repository<TEntity, TKey>

image

三、应用服务层注入 public IDbContextScopeFactory _dbContextScopeFactory { get; set; }

4XO$G259%H5(Z3HWZE0S%H5

四、使用方法

image

五:改造DbContextScope,加方法 Add DbContext Get(Type _DbContextType);

改动如下

image

相关链接:

https://github.com/shiningrise/DbContextScope/commit/8d48f584d0c1a159e2688f2dda5135356137d4b0

https://github.com/i66soft/osharp

https://github.com/mehdime/DbContextScope

原文地址:https://www.cnblogs.com/shiningrise/p/oshap3_DbContextScope.html