예제 #1
0
        private string CreateColumnSelectString(string columnName, AliasedSqlSubQuery subQuery)
        {
            var alias           = string.Format("{0} {1}", subQuery.TableIdentifier, columnName);
            var columnReference = new ColumnReference(columnName, subQuery.TableIdentifier, Escape);

            return(string.Format("{0} AS \"{1}\"", columnReference, alias));
        }
예제 #2
0
        private static string FromClauseTableIdentifier(AliasedSqlSubQuery subQuery)
        {
            if (subQuery.HasCustomAlias)
            {
                return(string.Format("{0} AS {1}", Escape(subQuery.TableName), Escape(subQuery.Alias)));
            }

            return(Escape(subQuery.TableName));
        }
예제 #3
0
 private string CreateJoinClause(SqlSubQueryJoin joinSpec, AliasedSqlSubQuery newSubQuery)
 {
     return(string.Format("LEFT OUTER JOIN {0} ON {1}.{2} = {3}.{4}",
                          FromClauseTableIdentifier(newSubQuery),
                          Escape(joinSpec.ParentSubQuery.TableIdentifier),
                          Escape(joinSpec.ParentPrimaryKeyColumnName),
                          Escape(joinSpec.ChildSubQuery.TableIdentifier),
                          Escape(joinSpec.ChildForeignKeyColumnName)));
 }
예제 #4
0
        public IEnumerable <string> GetColumnNamesToSelect(AliasedSqlSubQuery subQuery)
        {
            var hasExplicitColumnsToSelect = SubQueries.Any(x => x.HasExplicitlySpecifiedColumnsToSelect);

            if (hasExplicitColumnsToSelect)
            {
                return(subQuery.ExplicitlySpecifiedColumnsToSelect);
            }

            return(subQuery.AllSelectableColumnNames);
        }
예제 #5
0
        public static AliasedSqlSubQuery Create(string alias, Type type, IConventionReader conventionReader)
        {
            var subQuery = new AliasedSqlSubQuery()
            {
                Alias     = alias,
                TableName = conventionReader.GetTableName(type),
                AllSelectableColumnNames = conventionReader.GetSelectableColumNames(type).ToList(),
                PrimaryKeyColumnName     = conventionReader.TryGetPrimaryKeyColumnName(type)
            };

            return(subQuery);
        }
예제 #6
0
        private void CreateSubQuery(string alias, Type type)
        {
            var subQuery = AliasedSqlSubQuery.Create(alias, type, _conventionReader);

            SubQueries.Add(subQuery);
        }