/// <summary>
        /// Create projections context.
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="selectCommand"></param>
        /// <param name="groupByContext"></param>
        /// <param name="orderByContext"></param>
        /// <returns></returns>
        public ProjectionsContext CreateProjectionsContext(string sql, SelectCommand selectCommand, GroupByContext groupByContext, OrderByContext orderByContext)
        {
            ProjectionsSegment        projectionsSegment = selectCommand.Projections;
            ICollection <IProjection> projections        = GetProjections(sql, selectCommand.GetSimpleTableSegments(), projectionsSegment);
            ProjectionsContext        result             = new ProjectionsContext(projectionsSegment.GetStartIndex(), projectionsSegment.GetStopIndex(), projectionsSegment.IsDistinctRow(), projections);

            result.GetProjections().AddAll(GetDerivedGroupByColumns(projections, groupByContext, selectCommand));
            result.GetProjections().AddAll(GetDerivedOrderByColumns(projections, orderByContext, selectCommand));
            return(result);
        }
 private SimpleTableSegment Find(string tableNameOrAlias, SelectCommand selectCommand)
 {
     foreach (var simpleTableSegment in selectCommand.GetSimpleTableSegments())
     {
         if (tableNameOrAlias.Equals(simpleTableSegment.GetTableName().GetIdentifier().GetValue()) ||
             tableNameOrAlias.Equals(simpleTableSegment.GetAlias()))
         {
             return(simpleTableSegment);
         }
     }
     throw new ShardingException("can not find owner from table.");
 }