Example #1
0
 /// <summary>
 /// 执行读取数据使用的工作
 /// 使用通用的仓储,并返回处理结果
 /// </summary>
 /// <typeparam name="TData">数据类型</typeparam>
 /// <typeparam name="TResult">结果类型</typeparam>
 /// <param name="func">工作内容</param>
 public static TResult ReadData <TData, TResult>(Func <GenericRepository <TData>, TResult> func)
     where TData : class, IEntity
 {
     return(Read(context => {
         var repository = RepositoryResolver.Resolve <TData>(context);
         return func(repository);
     }));
 }
Example #2
0
 /// <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);
     }));
 }
Example #3
0
 /// <summary>
 /// 执行读取数据使用的工作
 /// 使用通用的仓储
 /// </summary>
 /// <typeparam name="TData">数据类型</typeparam>
 /// <param name="func">工作内容</param>
 public static void ReadData <TData>(Action <GenericRepository <TData> > func)
     where TData : class, IEntity
 {
     Read(context => {
         var repository = RepositoryResolver.Resolve <TData>(context);
         func(repository);
     });
 }
Example #4
0
 /// <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);
     });
 }