GetFullSort() private method

private GetFullSort ( ) : IEnumerable
return IEnumerable
        /// <summary>
        /// core build query function. start point
        /// </summary>
        /// <param name="expr"></param>
        /// <param name="paginate"></param>
        /// <param name="isCountQuery"></param>
        /// <param name="remoteGrouping"></param>
        /// <returns></returns>
        Expression BuildCore(Expression expr, bool paginate = false, bool isCountQuery = false, bool remoteGrouping = false)
        {
            var queryableType        = typeof(Queryable);
            var genericTypeArguments = new[] { typeof(T) };

            // call expression with filter
            if (_loadOptions.HasFilter)
            {
                expr = Expression.Call(queryableType, "Where", genericTypeArguments, expr, Expression.Quote(new FilterExpressionCompiler <T>(_guardNulls).Compile(_loadOptions.Filter)));
            }

            if (!isCountQuery)
            {
                if (!remoteGrouping)
                {
                    if (_loadOptions.HasAnySort)
                    {
                        expr = new SortExpressionCompiler <T>(_guardNulls).Compile(expr, _loadOptions.GetFullSort());
                    }
                    if (_loadOptions.HasAnySelect && _loadOptions.UseRemoteSelect)
                    {
                        expr = new SelectExpressionCompiler <T>(_guardNulls).Compile(expr, _loadOptions.GetFullSelect());
#if (NET40)
                        genericTypeArguments = expr.Type.GetGenericArguments();
#elif (NETSTANDARD1_0 || NETSTANDARD1_1 || NETSTANDARD1_2 || NETSTANDARD1_3 || NETSTANDARD1_4 || NETSTANDARD1_5 || NETSTANDARD1_6 || NETSTANDARD2_0)
                        genericTypeArguments = expr.Type.GetTypeInfo().IsGenericTypeDefinition ? expr.Type.GetTypeInfo().GenericTypeParameters : expr.Type.GetTypeInfo().GenericTypeArguments;
#elif (NETCOREAPP1_0 || NETCOREAPP1_1 || NETCOREAPP2_0 || NETCOREAPP2_1)
                        IEnumerable <Type> arguments = expr.Type.IsGenericTypeDefinition
                                ? expr.Type.GenericTypeParameters
                                : expr.Type.GenericTypeArguments;
                        genericTypeArguments = arguments.Select(x => x.GetTypeInfo()).ToArray();
#endif
                    }
                }
                else
                {
                    expr = new RemoteGroupExpressionCompiler <T>(_guardNulls, _loadOptions.Group, _loadOptions.TotalSummary, _loadOptions.GroupSummary).Compile(expr);
                }

                if (paginate)
                {
                    if (_loadOptions.Skip > 0)
                    {
                        expr = Expression.Call(queryableType, "Skip", genericTypeArguments, expr, Expression.Constant(_loadOptions.Skip));
                    }

                    if (_loadOptions.Take > 0)
                    {
                        expr = Expression.Call(queryableType, "Take", genericTypeArguments, expr, Expression.Constant(_loadOptions.Take));
                    }
                }
            }

            if (isCountQuery)
            {
                expr = Expression.Call(queryableType, "Count", genericTypeArguments, expr);
            }

            return(expr);
        }
        Expression BuildCore(Expression expr, bool paginate = false, bool isCountQuery = false, bool remoteGrouping = false)
        {
            var queryableType        = typeof(Queryable);
            var genericTypeArguments = new[] { typeof(T) };

            if (_loadOptions.HasFilter)
            {
                expr = Expression.Call(queryableType, "Where", genericTypeArguments, expr, Expression.Quote(new FilterExpressionCompiler <T>(_guardNulls).Compile(_loadOptions.Filter)));
            }

            if (!isCountQuery)
            {
                if (!remoteGrouping)
                {
                    if (_loadOptions.HasAnySort)
                    {
                        expr = new SortExpressionCompiler <T>(_guardNulls).Compile(expr, _loadOptions.GetFullSort());
                    }
                    if (_loadOptions.HasSelect)
                    {
                        expr = new SelectExpressionCompiler <T>(_guardNulls).Compile(expr, _loadOptions.Select);
                        genericTypeArguments = expr.Type.GetGenericArguments();
                    }
                }
                else
                {
                    expr = new RemoteGroupExpressionCompiler <T>(_loadOptions.Group, _loadOptions.TotalSummary, _loadOptions.GroupSummary).Compile(expr);
                }

                if (paginate)
                {
                    if (_loadOptions.Skip > 0)
                    {
                        expr = Expression.Call(queryableType, "Skip", genericTypeArguments, expr, Expression.Constant(_loadOptions.Skip));
                    }

                    if (_loadOptions.Take > 0)
                    {
                        expr = Expression.Call(queryableType, "Take", genericTypeArguments, expr, Expression.Constant(_loadOptions.Take));
                    }
                }
            }

            if (isCountQuery)
            {
                expr = Expression.Call(queryableType, "Count", genericTypeArguments, expr);
            }

            return(expr);
        }
示例#3
0
        Expression BuildCore(ParameterExpression param, bool paginate = false, bool isCountQuery = false, bool remoteGrouping = false)
        {
            var queryableType        = typeof(Queryable);
            var genericTypeArguments = new[] { typeof(T) };

            Expression body = param;

            if (_loadOptions.Filter != null)
            {
                body = Expression.Call(queryableType, "Where", genericTypeArguments, body, new FilterExpressionCompiler <T>(_guardNulls).Compile(_loadOptions.Filter));
            }

            if (!isCountQuery)
            {
                if (!remoteGrouping)
                {
                    if (_loadOptions.HasAnySort)
                    {
                        body = new SortExpressionCompiler <T>(_guardNulls).Compile(body, _loadOptions.GetFullSort());
                    }
                }
                else
                {
                    body = new RemoteGroupExpressionCompiler <T>(_loadOptions.Group, _loadOptions.TotalSummary, _loadOptions.GroupSummary).Compile(body);
                }

                if (paginate)
                {
                    if (_loadOptions.Skip > 0)
                    {
                        body = Expression.Call(queryableType, "Skip", genericTypeArguments, body, Expression.Constant(_loadOptions.Skip));
                    }

                    if (_loadOptions.Take > 0)
                    {
                        body = Expression.Call(queryableType, "Take", genericTypeArguments, body, Expression.Constant(_loadOptions.Take));
                    }
                }
            }

            if (isCountQuery)
            {
                body = Expression.Call(queryableType, "Count", genericTypeArguments, body);
            }

            return(body);
        }