/// <summary> /// 执行修改数据使用的工作 /// 使用指定的仓储,并返回处理结果 /// </summary> /// <typeparam name="TRepository">仓储类型</typeparam> /// <typeparam name="TResult">结果类型</typeparam> /// <param name="func">工作内容</param> public static TResult WriteRepository <TRepository, TResult>(Func <TRepository, TResult> func) where TRepository : IRepository { return(Write(context => { var repository = RepositoryResolver.ResolveRepository <TRepository>(context); return func(repository); })); }
/// <summary> /// 执行修改数据使用的工作 /// 使用指定的仓储 /// </summary> /// <typeparam name="TRepository">仓储类型</typeparam> /// <param name="func">工作内容</param> public static void WriteRepository <TRepository>(Action <TRepository> func) where TRepository : IRepository { Write(context => { var repository = RepositoryResolver.ResolveRepository <TRepository>(context); func(repository); }); }