public QueryUnderConstruction AddOrderByClause(SqlOrderbyClause orderBy, TranslationContext context) { QueryUnderConstruction result = context.PackageCurrentQueryIfNeccessary(); result.orderByClause = orderBy; foreach (Binding binding in context.CurrentSubqueryBinding.TakeBindings()) { result.AddBinding(binding); } return(result); }
/// <summary> /// Add a Where clause to a query; may need to create a new query. /// </summary> /// <param name="whereClause">Clause to add.</param> /// <param name="context">The translation context.</param> /// <returns>A new query containing the specified Where clause.</returns> public QueryUnderConstruction AddWhereClause(SqlWhereClause whereClause, TranslationContext context) { QueryUnderConstruction result = context.PackageCurrentQueryIfNeccessary(); whereClause = QueryUnderConstruction.CombineWithConjunction(result.whereClause, whereClause); result.whereClause = whereClause; foreach (Binding binding in context.CurrentSubqueryBinding.TakeBindings()) { result.AddBinding(binding); } return(result); }
public QueryUnderConstruction AddOffsetSpec(SqlOffsetSpec offsetSpec, TranslationContext context) { QueryUnderConstruction result = context.PackageCurrentQueryIfNeccessary(); if (result.offsetSpec != null) { // Skip(A).Skip(B) => Skip(A + B) result.offsetSpec = SqlOffsetSpec.Create(result.offsetSpec.Offset + offsetSpec.Offset); } else { result.offsetSpec = offsetSpec; } return(result); }
public QueryUnderConstruction AddOffsetSpec(SqlOffsetSpec offsetSpec, TranslationContext context) { QueryUnderConstruction result = context.PackageCurrentQueryIfNeccessary(); if (result.offsetSpec != null) { // Skip(A).Skip(B) => Skip(A + B) long offsetA = QueryUnderConstruction.GetOffsetCount(result.offsetSpec); long offsetB = QueryUnderConstruction.GetOffsetCount(offsetSpec); result.offsetSpec = SqlOffsetSpec.Create(SqlNumberLiteral.Create(offsetA + offsetB)); } else { result.offsetSpec = offsetSpec; } return(result); }
/// <summary> /// Add a Select clause to a query; may need to create a new subquery. /// </summary> /// <param name="select">Select clause to add.</param> /// <param name="context">The translation context.</param> /// <returns>A new query containing a select clause.</returns> public QueryUnderConstruction AddSelectClause(SqlSelectClause select, TranslationContext context) { QueryUnderConstruction result = context.PackageCurrentQueryIfNeccessary(); // If result SelectClause is not null, or both result selectClause and select has Distinct // then it is unexpected since the SelectClause will be overwritten. if (!((result.selectClause != null && result.selectClause.HasDistinct && selectClause.HasDistinct) || result.selectClause == null)) { throw new DocumentQueryException("Internal error: attempting to overwrite SELECT clause"); } result.selectClause = select; foreach (Binding binding in context.CurrentSubqueryBinding.TakeBindings()) { result.AddBinding(binding); } return(result); }