Esempio n. 1
0
 private static MethodInfo GetGenericMethod(this DataRequest request, string methodName)
 => methodName.GetMethod().MakeGenericMethod
 (
     typeof(BaseModelClass).GetTypeInfo().Assembly.GetType(request.ModelType),
     typeof(BaseDataClass).GetTypeInfo().Assembly.GetType(request.DataType)
 );
Esempio n. 2
0
 public static Task <TReturn> InvokeGenericMethod <TReturn>(this DataRequest request, string methodName, IContextRepository contextRepository, IMapper mapper)
 => (Task <TReturn>)request
 .GetGenericMethod(methodName)
 .Invoke(null, new object[] { request, contextRepository, mapper });
Esempio n. 3
0
 public static async Task <bool> Delete <TModel, TData>(this DataRequest request, IContextRepository contextRepository)
     where TModel : BaseModelClass
     where TData : BaseDataClass
 => await contextRepository.DeleteAsync <TModel, TData>(ExpressionBuilder.Expression <TModel>(request.Options.CreateDataSourceRequest().Filters));
Esempio n. 4
0
 public static Task <bool> InvokeGenericDeleteMethod(this DataRequest request, string methodName, IContextRepository contextRepository)
 => (Task <bool>)request
 .GetGenericMethod(methodName)
 .Invoke(null, new object[] { request, contextRepository });
Esempio n. 5
0
        public static async Task <IEnumerable <dynamic> > GetDynamicSelect <TModel, TData>(this DataRequest request, IContextRepository contextRepository, IMapper mapper)
            where TModel : BaseModelClass
            where TData : BaseDataClass
        {
            Expression <Func <IQueryable <TModel>, IEnumerable <dynamic> > > exp = Expression.Parameter(typeof(IQueryable <TModel>), "q").BuildLambdaExpression <IQueryable <TModel>, IEnumerable <dynamic> >
                                                                                   (
                p => request.Distinct == true
                    ? request.Options.CreateDataSourceRequest()
                .CreateUngroupedMethodExpression(p.GetSelectNew <TModel>(request.Selects))
                .GetDistinct()
                    : request.Options.CreateDataSourceRequest()
                .CreateUngroupedMethodExpression(p.GetSelectNew <TModel>(request.Selects))
                                                                                   );

            return(await contextRepository.QueryAsync <TModel, TData, IEnumerable <dynamic>, IEnumerable <dynamic> >
                   (
                       exp,
                       mapper.MapExpansion(request.SelectExpandDefinition)
                   ));
        }