示例#1
0
文件: Cases.cs 项目: daszat/zetbox
        public void DoNewCompoundObjectPropertyList(ObjectClass objClass, CompoundObjectProperty cprop)
        {
            if (!PreMigration(PropertyMigrationEventType.Add, null, cprop))
                return;

            Log.InfoFormat("New CompoundObject Property List: {0}", cprop.Name);
            var tblName = db.GetTableName(cprop.Module.SchemaName, cprop.GetCollectionEntryTable());
            string fkName = Construct.ForeignKeyColumnName(cprop);

            // TODO: Support nested CompoundObject
            string valPropIndexName = cprop.Name + "Index";
            string assocName = cprop.GetAssociationName();
            bool hasPersistentOrder = cprop.HasPersistentOrder;

            db.CreateTable(tblName, true);
            db.CreateColumn(tblName, fkName, System.Data.DbType.Int32, 0, 0, false);

            foreach (ValueTypeProperty p in cprop.CompoundObjectDefinition.Properties)
            {
                CheckValueTypePropertyHasWarnings(p);
                db.CreateColumn(tblName, Construct.ColumnName(p, cprop.Name), p.GetDbType(), p.GetSize(), p.GetScale(), true, null);
            }

            if (hasPersistentOrder)
            {
                db.CreateColumn(tblName, valPropIndexName, System.Data.DbType.Int32, 0, 0, false);
            }
            db.CreateFKConstraint(tblName, objClass.GetTableRef(db), fkName, assocName, true);
            db.CreateIndex(tblName, Construct.IndexName(tblName.Name, fkName), false, false, fkName);

            PostMigration(PropertyMigrationEventType.Add, null, cprop);
        }
示例#2
0
文件: Cases.cs 项目: jrgcubano/zetbox
        public void DoNewCompoundObjectPropertyList(ObjectClass objClass, CompoundObjectProperty cprop)
        {
            Log.InfoFormat("New CompoundObject Property List: {0}", cprop.Name);
            var tblName = db.GetTableName(cprop.Module.SchemaName, cprop.GetCollectionEntryTable());
            string fkName = "fk_" + cprop.ObjectClass.Name;

            // TODO: Support neested CompoundObject
            string valPropIndexName = cprop.Name + "Index";
            string assocName = cprop.GetAssociationName();
            bool hasPersistentOrder = cprop.HasPersistentOrder;

            db.CreateTable(tblName, true);
            db.CreateColumn(tblName, fkName, System.Data.DbType.Int32, 0, 0, false);

            foreach (ValueTypeProperty p in cprop.CompoundObjectDefinition.Properties)
            {
                db.CreateColumn(tblName, Construct.NestedColumnName(p.Name, cprop.Name), p.GetDbType(), p.GetSize(), p.GetScale(), true, SchemaManager.GetDefaultConstraint(cprop));
            }

            if (hasPersistentOrder)
            {
                db.CreateColumn(tblName, valPropIndexName, System.Data.DbType.Int32, 0, 0, false);
            }
            db.CreateFKConstraint(tblName, db.GetTableName(objClass.Module.SchemaName, objClass.TableName), fkName, assocName, true);
            db.CreateIndex(tblName, Construct.IndexName(tblName.Name, fkName), false, false, fkName);
        }
示例#3
0
文件: Cases.cs 项目: daszat/zetbox
        public void DoDeleteCompoundObjectPropertyList(ObjectClass objClass, CompoundObjectProperty savedCProp, string prefix)
        {
            if (!PreMigration(PropertyMigrationEventType.Delete, savedCProp, null))
                return;

            Log.InfoFormat("Delete CompoundObject Property List: {0}", savedCProp.Name);
            var tblName = db.GetTableName(savedCProp.Module.SchemaName, savedCProp.GetCollectionEntryTable());
            db.DropTable(tblName);

            PostMigration(PropertyMigrationEventType.Delete, savedCProp, null);
        }