protected override void ApplyNodeSpecificSemantics(QueryModel queryModel, ClauseGenerationContext clauseGenerationContext) { if (_keySelector.ReturnType != typeof(string)) { throw new ArgumentException("Only strings are supported when providing order comparer"); } bool caseInsensitive; if (ReferenceEquals(ConstantExpression.Value, StringComparer.InvariantCultureIgnoreCase) || ReferenceEquals(ConstantExpression.Value, StringComparer.OrdinalIgnoreCase)) { caseInsensitive = true; } else if (ReferenceEquals(ConstantExpression.Value, StringComparer.InvariantCulture) || ReferenceEquals(ConstantExpression.Value, StringComparer.Ordinal)) { caseInsensitive = false; } else { throw new ArgumentException("Only ordinal and invariant StringComparer static comparer members are allowed as comparer"); } var orderByClause = new OrderByComparerClause(caseInsensitive, new Ordering(GetResolvedKeySelector(clauseGenerationContext), _orderingDirection)); queryModel.BodyClauses.Add(orderByClause); }
public IBodyClause Clone(CloneContext cloneContext) { var clone = new OrderByComparerClause(CaseInsensitive); foreach (var ordering in Orderings) { var clonedOrdering = ordering.Clone(cloneContext); clone.Orderings.Add(clonedOrdering); } return(clone); }