Beispiel #1
0
        private static TQueryable CreateSortedMethodCall <TSource, TDest, TQueryable>(IQueryable <TSource> query, string methodName, string sortedPropertySourceName) where TSource : class where TDest : class where TQueryable : class, IQueryable <TSource>
        {
            MapperConfiguration <TSource, TDest> mapper = ExpressionMapper.GetMapper <TSource, TDest>();
            var prop   = mapper.GetLambdaDest(sortedPropertySourceName);
            var lambda = mapper.GetSortedExpression(sortedPropertySourceName);
            MethodCallExpression resultExp = Expression.Call(typeof(Queryable), methodName, new[]
            {
                typeof(TSource),
                prop.Type
            }, query.Expression, Expression.Quote(lambda));

            return(query.Provider.CreateQuery <TSource>(resultExp) as TQueryable);
        }