コード例 #1
0
        public SchemaBuilder CreateMapIndexTable(string name, Action <CreateTableCommand> table)
        {
            try
            {
                var createTable   = new CreateTableCommand(Prefix(name));
                var collection    = CollectionHelper.Current;
                var documentTable = collection.GetPrefixedName(Store.DocumentTable);

                createTable
                .Column <int>("Id", column => column.PrimaryKey().Identity().NotNull())
                .Column <int>("DocumentId");

                table(createTable);
                Execute(_builder.CreateSql(createTable));

                CreateForeignKey("FK_" + name, name, new[] { "DocumentId" }, documentTable, new[] { "Id" });
            }
            catch
            {
                if (ThrowOnError)
                {
                    throw;
                }
            }

            return(this);
        }
コード例 #2
0
ファイル: SchemaBuilder.cs プロジェクト: verystack/yessql
        public ISchemaBuilder CreateMapIndexTable(Type indexType, Action <ICreateTableCommand> table, string collection)
        {
            try
            {
                var indexName     = indexType.Name;
                var indexTable    = TableNameConvention.GetIndexTable(indexType, collection);
                var createTable   = new CreateTableCommand(Prefix(indexTable));
                var documentTable = TableNameConvention.GetDocumentTable(collection);

                createTable
                .Column <int>("Id", column => column.PrimaryKey().Identity().NotNull())
                .Column <int>("DocumentId");

                table(createTable);
                Execute(_builder.CreateSql(createTable));

                CreateForeignKey("FK_" + (collection ?? "") + indexName, indexTable, new[] { "DocumentId" }, documentTable, new[] { "Id" });
            }
            catch
            {
                if (ThrowOnError)
                {
                    throw;
                }
            }

            return(this);
        }
コード例 #3
0
ファイル: SchemaBuilder.cs プロジェクト: ym1100/AceSaaS
        public SchemaBuilder CreateTable(string name, Action <CreateTableCommand> table)
        {
            try
            {
                var createTable = new CreateTableCommand(Prefix(name));
                table(createTable);
                Execute(_builder.CreateSql(createTable));
            }
            catch
            {
                if (ThrowOnError)
                {
                    throw;
                }
            }

            return(this);
        }
コード例 #4
0
 public static IEnumerable <string> CreateSql(this ICommandInterpreter builder, ISchemaCommand command)
 {
     return(builder.CreateSql(new[] { command }));
 }