Remotion.Linq.SqlBackend.SqlGeneration.DefaultSqlGenerationStage.GenerateTextForOrdering C# (CSharp) Метод

GenerateTextForOrdering() публичный Метод

public GenerateTextForOrdering ( ISqlCommandBuilder commandBuilder, Remotion.Linq.Clauses.Ordering ordering ) : void
commandBuilder ISqlCommandBuilder
ordering Remotion.Linq.Clauses.Ordering
Результат void
    public void GenerateTextForOrdering (ISqlCommandBuilder commandBuilder, Ordering ordering)
    {
      ArgumentUtility.CheckNotNull ("commandBuilder", commandBuilder);
      ArgumentUtility.CheckNotNull ("ordering", ordering);
      
      if (ordering.Expression.NodeType == ExpressionType.Constant || ordering.Expression is SqlLiteralExpression)
      {
        commandBuilder.Append ("(SELECT ");
        GenerateTextForOrderByExpression (commandBuilder, ordering.Expression);
        commandBuilder.Append (")");
      }
      else
        GenerateTextForOrderByExpression (commandBuilder, ordering.Expression);

      commandBuilder.AppendFormat (string.Format (" {0}", ordering.OrderingDirection.ToString ().ToUpper ()));
    }

Usage Example

    public void GenerateTextForOrdering ()
    {
      var ordering = new Ordering (Expression.Constant (1), OrderingDirection.Asc);

      var stage = new DefaultSqlGenerationStage();

      stage.GenerateTextForOrdering (_commandBuilder, ordering);

      Assert.That (_commandBuilder.GetCommandText(), Is.EqualTo ("(SELECT @1) ASC"));
    }