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)); }
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)); }
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))); }
public IEnumerable <string> GetColumnNamesToSelect(AliasedSqlSubQuery subQuery) { var hasExplicitColumnsToSelect = SubQueries.Any(x => x.HasExplicitlySpecifiedColumnsToSelect); if (hasExplicitColumnsToSelect) { return(subQuery.ExplicitlySpecifiedColumnsToSelect); } return(subQuery.AllSelectableColumnNames); }
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); }
private void CreateSubQuery(string alias, Type type) { var subQuery = AliasedSqlSubQuery.Create(alias, type, _conventionReader); SubQueries.Add(subQuery); }