Пример #1
0
        private SimpleTableSegment GetTableSegment(IProjectionSegment projection)
        {
            var owner = GetTableOwner(projection);

            if (owner != null && IsTable(owner, GetSqlCommand().GetSimpleTableSegments()))
            {
                return(new SimpleTableSegment(owner.GetStartIndex(), owner.GetStopIndex(), owner.GetIdentifier()));
            }
            return(null);
        }
Пример #2
0
 private OwnerSegment GetTableOwner(IProjectionSegment projection)
 {
     if (projection is IOwnerAvailable ownerAvailable)
     {
         return(ownerAvailable.GetOwner());
     }
     if (projection is ColumnProjectionSegment columnProjectionSegment)
     {
         return(columnProjectionSegment.GetColumn().GetOwner());
     }
     return(null);
 }
Пример #3
0
 /**
  * Create projection.
  *
  * @param sql SQL
  * @param tableSegments table segments
  * @param projectionSegment projection segment
  * @return projection
  */
 public IProjection CreateProjection(string sql, ICollection <SimpleTableSegment> tableSegments, IProjectionSegment projectionSegment)
 {
     if (projectionSegment is ShorthandProjectionSegment shorthandProjectionSegment)
     {
         return(CreateProjection(tableSegments, shorthandProjectionSegment));
     }
     if (projectionSegment is ColumnProjectionSegment columnProjectionSegment)
     {
         return(CreateProjection(columnProjectionSegment));
     }
     if (projectionSegment is ExpressionProjectionSegment expressionProjectionSegment)
     {
         return(CreateProjection(expressionProjectionSegment));
     }
     if (projectionSegment is AggregationDistinctProjectionSegment aggregationDistinctProjectionSegment)
     {
         return(CreateProjection(sql, aggregationDistinctProjectionSegment));
     }
     if (projectionSegment is AggregationProjectionSegment aggregationProjectionSegment)
     {
         return(CreateProjection(sql, aggregationProjectionSegment));
     }
     // TODO subquery
     return(null);
 }