System.Data.Common.CommandTrees.ExpressionBuilder.DbExpressionBuilder.Sort(System.Data.Common.CommandTrees.DbExpressionBinding, System.Collections.Generic.IEnumerable)

Here are the examples of the csharp api class System.Data.Common.CommandTrees.ExpressionBuilder.DbExpressionBuilder.Sort(System.Data.Common.CommandTrees.DbExpressionBinding, System.Collections.Generic.IEnumerable) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

6 Examples 7

1. Example

View license
public static DbSortExpression OrderBy(this DbExpression source, Func<DbExpression, DbExpression> sortKey)
        {
            DbExpression keyExpression;
            DbExpressionBinding input = ConvertToBinding(source, sortKey, "sortKey", out keyExpression);
            DbSortClause sortClause = DbExpressionBuilder.ToSortClause(keyExpression);
            return DbExpressionBuilder.Sort(input, new DbSortClause[] { sortClause });
        }

2. Example

View license
public static DbSortExpression OrderBy(this DbExpression source, Func<DbExpression, DbExpression> sortKey, string collation)
        {
            DbExpression keyExpression;
            DbExpressionBinding input = ConvertToBinding(source, sortKey, "sortKey", out keyExpression);
            DbSortClause sortClause = DbExpressionBuilder.ToSortClause(keyExpression, collation);
            return DbExpressionBuilder.Sort(input, new DbSortClause[] { sortClause });
        }

3. Example

View license
public static DbSortExpression OrderByDescending(this DbExpression source, Func<DbExpression, DbExpression> sortKey)
        {
            DbExpression keyExpression;
            DbExpressionBinding input = ConvertToBinding(source, sortKey, "sortKey", out keyExpression);
            DbSortClause sortClause = DbExpressionBuilder.ToSortClauseDescending(keyExpression);
            return DbExpressionBuilder.Sort(input, new DbSortClause[] { sortClause });
        }

4. Example

View license
public static DbSortExpression OrderByDescending(this DbExpression source, Func<DbExpression, DbExpression> sortKey, string collation)
        {
            DbExpression keyExpression;
            DbExpressionBinding input = ConvertToBinding(source, sortKey, "sortKey", out keyExpression);
            DbSortClause sortClause = DbExpressionBuilder.ToSortClauseDescending(keyExpression, collation);
            return DbExpressionBuilder.Sort(input, new DbSortClause[] { sortClause });
        }

5. Example

View license
public override DbExpression Visit(DbSortExpression expression)
        {
            EntityUtil.CheckArgumentNull(expression, "expression");

            DbExpression result = expression;

            DbExpressionBinding newInput = this.VisitExpressionBindingEnterScope(expression.Input);
            IList<DbSortClause> newSortOrder = this.VisitSortOrder(expression.SortOrder);
            this.ExitScope();

            if (!object.ReferenceEquals(expression.Input, newInput) ||
                !object.ReferenceEquals(expression.SortOrder, newSortOrder))
            {
                result = CqtBuilder.Sort(newInput, newSortOrder);
            }
            NotifyIfChanged(expression, result);
            return result;
        }

6. Example

View license
private static DbSortExpression CreateThenBy(DbSortExpression source, Func<DbExpression, DbExpression> sortKey, bool ascending, string collation, bool useCollation)
        {
            EntityUtil.CheckArgumentNull(source, "source");
            EntityUtil.CheckArgumentNull(sortKey, "sortKey");
            DbExpression sortKeyResult = sortKey(source.Input.Variable);
            DbSortClause sortClause;
            if (useCollation)
            {
                sortClause = (ascending ? DbExpressionBuilder.ToSortClause(sortKeyResult, collation) : DbExpressionBuilder.ToSortClauseDescending(sortKeyResult, collation));
            }
            else
            {
                sortClause = (ascending ? DbExpressionBuilder.ToSortClause(sortKeyResult) : DbExpressionBuilder.ToSortClauseDescending(sortKeyResult));
            }

            List<DbSortClause> newSortOrder = new List<DbSortClause>(source.SortOrder.Count + 1);
            newSortOrder.AddRange(source.SortOrder);
            newSortOrder.Add(sortClause);

            return DbExpressionBuilder.Sort(source.Input, newSortOrder);
        }