コード例 #1
0
        public void CreateProperty(CreatePropertyCommand createPropertyCommand, object sender, ExecutionCancelEventArgs e)
        {
            IEngine engine = sender as IEngine;

            IDatabaseService databaseService = engine.GetService <IDatabaseService>();
            ISqlService      sqlService      = engine.GetService <ISqlService>();
            ISchemaService   schemaService   = engine.GetService <ISchemaService>();

            //Begins a new transaction or gets the current transaction
            IDbTransaction transaction = databaseService.EnsureTransaction();

            string tableName = schemaService.GetTableForClass(createPropertyCommand.ClassName);
            DbType dbType    = databaseService.GetDbType(createPropertyCommand.Type, createPropertyCommand.StringLength);

            //Create the database table with the primary key column
            sqlService.CreateColumn(transaction, tableName, createPropertyCommand.ColumnName, dbType, createPropertyCommand.Nullable);
        }