v2.6.100
#867
Replies: 2 comments
-
IUnitOfWork.States使用者决定,用于扩展工作单元。 场景:跨方法失掉上下文的时候 比如给 IUnitOfWork 增加扩展方法的时候,下次再使用 uow,还知道存的什么内容 public static IBaseRepository<T> Crud<T>(this IUnitOfWork uow)
{
if (uow.States.TryGetValue(typeof(T).FullName, out var repo)) return repo;
repo = uow.Orm.GetRepository<T>();
repo.UnitOfWork = uow;
uow.States.Add(typeof(T).FullName, repo);
return repo;
}
//使用 States 属性,工作单元比较好扩展
uow.Curd<Topic>().Insert(xxx);
uow.Curd<Topic>().Update(xxx); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
v2.5.200
This discussion was created from the release v2.6.100.
Beta Was this translation helpful? Give feedback.
All reactions