コード例 #1
0
 public SqlDropTable ParseDropTable(IFromQuery table)
 {
     return(new SqlDropTable()
     {
         TableName = table.TableName,
     });
 }
コード例 #2
0
        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,
            });
        }
コード例 #3
0
 public SqlDropForeignKey ParseDropForeignKey(IFromQuery table, ForeignKey foreignKey)
 {
     return(new SqlDropForeignKey()
     {
         TableName = table.TableName,
         ForeignKeyName = foreignKey.Name,
     });
 }
コード例 #4
0
 public SqlDropColumn ParseDropColumn(IFromQuery table, Column column)
 {
     return(new SqlDropColumn()
     {
         TableName = table.TableName,
         ColumnName = column.SqlName,
     });
 }
コード例 #5
0
 public SqlDropIndex ParseDropIndex(IFromQuery table, Index index)
 {
     return(new SqlDropIndex()
     {
         TableName = table.TableName,
         IndexName = index.Name,
     });
 }
コード例 #6
0
        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);
        }
コード例 #7
0
        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,
                }
            });
        }
コード例 #8
0
 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(),
     });
 }
コード例 #9
0
 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,
         },
     });
 }
コード例 #10
0
        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,
                },
            });
        }
コード例 #11
0
 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)));
 }