public SqlDropTable ParseDropTable(IFromQuery table) { return(new SqlDropTable() { TableName = table.TableName, }); }
private SqlQuery ParseFromQuery(IFromQuery fromQuery, out SqlSubQueryResult selectResult) { var tableAlias = AliasProvider.CreateAlias(); selectResult = new SqlSubQueryResult() { Members = new List <SqlMember>() }; foreach (var column in fromQuery.Columns) { selectResult.Members.Add(new SqlTableFieldMember() { MemberName = column.MemberName, MemberInfo = column.PropertyInfo, SqlName = column.SqlName, TableAlias = tableAlias, TableType = fromQuery.TableType, FieldType = column.OriginalType, }); } return(new SqlQuery() { From = new SqlFromTable() { TableName = fromQuery.TableName, }, FromAlias = tableAlias, }); }
public SqlDropForeignKey ParseDropForeignKey(IFromQuery table, ForeignKey foreignKey) { return(new SqlDropForeignKey() { TableName = table.TableName, ForeignKeyName = foreignKey.Name, }); }
public SqlDropColumn ParseDropColumn(IFromQuery table, Column column) { return(new SqlDropColumn() { TableName = table.TableName, ColumnName = column.SqlName, }); }
public SqlDropIndex ParseDropIndex(IFromQuery table, Index index) { return(new SqlDropIndex() { TableName = table.TableName, IndexName = index.Name, }); }
private List <string> GetFieldNamesFromMemberNames(IFromQuery fromQuery, List <string> members) { var columns = new List <string>(); foreach (var keyColumn in members) { var fromColumns = fromQuery.Columns.Where(c => c.MemberName == keyColumn).First(); columns.Add(fromColumns.SqlName); } return(columns); }
public SqlAddIndex ParseAddIndex(IFromQuery table, Index index) { var columns = GetFieldNamesFromMemberNames(table, index.Columns); return(new SqlAddIndex() { TableName = table.TableName, Index = new SqlIndex() { Name = index.Name, Unique = index.Unique, Columns = columns, } }); }
public SqlCreateTable ParseCreateTable(IFromQuery table) { return(new SqlCreateTable() { TableName = table.TableName, Columns = table.Columns.Select(c => new SqlColumn() { Name = c.SqlName, Type = c.BaseType, Nullable = c.Nullable, PrimaryKey = c.PrimaryKey, PrimaryKeyAutoIncrement = c.PrimaryKeyAutoIncrement, SqlType = c.SqlType, }).ToList(), }); }
public SqlAddColumn ParseAddColumn(IFromQuery table, Column column) { return(new SqlAddColumn() { TableName = table.TableName, Column = new SqlColumn() { Name = column.SqlName, Nullable = column.Nullable, PrimaryKey = column.PrimaryKey, PrimaryKeyAutoIncrement = column.PrimaryKeyAutoIncrement, SqlType = column.SqlType, Type = column.BaseType, }, }); }
public SqlAddForeignKey ParseAddForeignKey(IFromQuery table, ForeignKey foreignKey) { var foreignQuery = table.Context.FromQueries.Where(q => q.TableType == foreignKey.ReferenceTableType).FirstOrDefault(); if (foreignQuery == null) { throw new InvalidOperationException("Foreign key referenced an invalid table type: " + foreignKey.ReferenceTableType.Name); } var columns = GetFieldNamesFromMemberNames(table, foreignKey.Columns); var referenceColumns = GetFieldNamesFromMemberNames(foreignQuery, foreignKey.ReferenceColumns); return(new SqlAddForeignKey() { TableName = table.TableName, ForeignKey = new SqlForeignKey() { Name = foreignKey.Name, ReferenceTableName = foreignQuery.TableName, Columns = columns, ReferenceColumns = referenceColumns, }, }); }
public static IJoinQuery <TDatabase, TTable1, TTable2> OuterJoin <TDatabase, TTable1, TTable2>(this IFromQuery <TDatabase, TTable1> fromQuery, Expression <Func <TDatabase, IEnumerable <TTable2> > > selector, Func <ParameterExpression, Expression> dynamicCondition) { return(fromQuery.OuterJoin(selector, MakeLambda <IJoinedRow <TTable1, TTable2>, bool>(dynamicCondition))); }