当前位置: 首页>>代码示例>>C#>>正文


C# Schema.Create方法代码示例

本文整理汇总了C#中Schema.Create方法的典型用法代码示例。如果您正苦于以下问题:C# Schema.Create方法的具体用法?C# Schema.Create怎么用?C# Schema.Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Schema的用法示例。


在下文中一共展示了Schema.Create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Setup

        public override void Setup()
        {
            base.Setup();

            _server = new Server(Server);

            var database = _server.Databases[TestDbName];
            if (database != null)
            {
                database.Drop();
            }

            _database = new Database(_server, TestDbName);
            _database.Create();
            var schema = new Schema(_database, CustomVersioningTableSchema);
            schema.Owner = "dbo";
            schema.Create();
        }
开发者ID:dradovic,项目名称:MigSharp,代码行数:18,代码来源:SqlServerIntegrationTests.cs

示例2: CreateSchema

 /// <summary>
 /// Creates a new schema in the database
 /// </summary>
 /// <param name="SchemaName">The name of the schema to create</param>
 public void CreateSchema(string SchemaName)
 {
     Schema schema = new Schema(_database, SchemaName);
     schema.Create();
 }
开发者ID:nathantownsend,项目名称:DALAPI,代码行数:9,代码来源:Database.cs

示例3: ExecuteButton_Click

        private void ExecuteButton_Click(object sender, EventArgs e)
        {
            Cursor csr = null;
            Database db;
            Schema spSchema;

            // Timing
            DateTime start = DateTime.Now;

            if (System.Windows.Forms.MessageBox.Show(this, Properties.Resources.ReallyCreate,
                this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                MessageBoxDefaultButton.Button2, 0) == DialogResult.No)
            {
                return;
            }

            try
            {
                csr = this.Cursor;   // Save the old cursor
                this.Cursor = Cursors.WaitCursor;   // Display the waiting cursor

                // Clear control
                ScriptTextBox.Clear();

                db = (Database)DatabasesComboBox.SelectedItem;

                // Create SmoDemo schema to contain stored procedures
                if (db.Schemas.Contains("SmoDemo") == false)
                {
                    spSchema = new Schema(db, "SmoDemo");
                    spSchema.Create();
                }
                else
                {
                    spSchema = db.Schemas["SmoDemo"];
                }

                // Limit the table properties returned to just those that we use
                SqlServerSelection.SetDefaultInitFields(typeof(Table),
                    new String[] { "Name" });

                // Limit the column properties returned to just those that we use
                SqlServerSelection.SetDefaultInitFields(typeof(Column),
                    new String[] { "Name", "DataType", "Length", "InPrimaryKey" });

                // Limit the stored procedure properties returned to just those that we use
                SqlServerSelection.SetDefaultInitFields(typeof(StoredProcedure),
                    new String[] { "Name", "Schema" });

                // Create a SELECT stored procedure for each table
                foreach (Table tbl in db.Tables)
                {
                    if (db.IsSystemObject == false)
                    {
                        CreateSelectProcedure(spSchema, tbl);
                    }
                }

                ScriptTextBox.AppendText(Properties.Resources.Completed);

                ScrollToBottom();

                sbrStatus.Text = Properties.Resources.Ready;
            }
            catch (SmoException ex)
            {
                ExceptionMessageBox emb = new ExceptionMessageBox(ex);
                emb.Show(this);
            }
            finally
            {
                // Clean up.
                this.Cursor = csr;  // Restore the original cursor

                // Timing
                TimeSpan diff = DateTime.Now - start;

                ScriptTextBox.AppendText(String.Format(
                    System.Threading.Thread.CurrentThread.CurrentCulture,
                    Environment.NewLine + Properties.Resources.ElapsedTime,
                    (diff.Minutes * 60) + diff.Seconds, diff.Milliseconds));
            }
        }
开发者ID:rcdosado,项目名称:SMO,代码行数:83,代码来源:CreateStoredProcs.cs

示例4: CheckSchema

        private bool CheckSchema(Database database, bool createManagementSchemaIfMissing)
        {
            var schema = database.Schemas[SchemaName];
            if (schema == null)
            {
                if (createManagementSchemaIfMissing)
                {
                    schema = new Schema(database, SchemaName);
                    schema.Create();
                }
                else
                {
                    _context.RaiseExecutionEvent(ExecutionEventType.Error, "The Gus management schema could not be found.");
                    return false;
                }
            }

            return true;
        }
开发者ID:defize,项目名称:Gus,代码行数:19,代码来源:DatabaseHelper.cs

示例5: Main


//.........这里部分代码省略.........
                foreach (Table t in newDB.Tables) if (!t.IsSystemObject) oldTables.Add(t);
                List<Trigger> oldTriggers = new List<Trigger>();
                foreach (Trigger t in newDB.Triggers) if (!t.IsSystemObject) oldTriggers.Add(t);
                //delete 'em
                foreach (Trigger t in oldTriggers) t.Drop();
                foreach (View v in oldViews) v.Drop();
                foreach (Table t in oldTables) t.Drop();
            }
            else
            {
                WriteLine(string.Format("Creating new database \"{0}\" ", newDatabase), OutputKind.Info);
                newDB = new Database(svr, newDatabase);
                newDB.Collation = db.Collation;
                newDB.DefaultSchema = db.DefaultSchema; //should it be "sysdba"?
                FileGroup dbFG = new FileGroup(newDB, "PRIMARY");
                newDB.FileGroups.Add(dbFG);

                //Now add primary db file to file group
                if (string.IsNullOrEmpty(databaseFileName))
                {
                    string oldDatabaseFilename = db.FileGroups[0].Files[0].FileName;
                    string directory = Path.GetDirectoryName(oldDatabaseFilename);
                    databaseFileName = directory + @"\" + newDatabase + ".mdf";
                }

                DataFile df1 = new DataFile(dbFG, "SalesLogix_Data");
                dbFG.Files.Add(df1);
                df1.FileName = databaseFileName;
                df1.Size = 10.0*1024.0;
                df1.GrowthType = FileGrowthType.Percent;
                df1.Growth = 25.0;
                try
                {
                    newDB.Create();
                }
                catch (Exception e)
                {
                    WriteLine(string.Format("Could not create database \"{0}\"", newDatabase), OutputKind.Error);
                    ReportException(e);
                    WarnAndExit("");
                }
            }

            //copy the users
            foreach (User oldUser in db.Users)
            {
                User newUser = newDB.Users[oldUser.Name];
                if (newUser == null)
                {
                    Notify("Processing user  " + oldUser.Name);
                    try
                    {
                        newUser = new User(newDB, oldUser.Name);
                        newUser.DefaultSchema = oldUser.DefaultSchema;
                        newUser.UserType = oldUser.UserType;
                        newUser.Login = oldUser.Login;
                        newDB.Users.Add(newUser);
                        newUser.Create();

                        StringCollection roles = oldUser.EnumRoles();
                        foreach (string role in roles) newUser.AddToRole(role);
                        newUser.Alter();
                    }
                    catch (Exception e)
                    {
                        ReportException(e);
开发者ID:Saleslogix,项目名称:SLXToolsContrib,代码行数:67,代码来源:Program.cs

示例6: GetSchema

 public Schema GetSchema()
 {
     if (null == _schema)
     {
         _schema = new Schema(GetDatabase(), "Schema1");
         _schema.Create();
         _toDrop.Add(_schema);
     }
     return _schema;
 }
开发者ID:jshield,项目名称:sqlperms,代码行数:10,代码来源:TestHelper.cs

示例7: Reload

        public void Reload()
        {
            using (var connector = Connect()) {
                var connection = connector.Connection;
                var server = GetServer(connection);
                var database = GetDatabase(server);
                if (!database.Schemas.Contains(_tableConfiguration.Schema)) {
                    var schema = new Schema(database, _tableConfiguration.Schema);
                    database.Schemas.Add(schema);
                    schema.Create();
                }

                _partTable = new PartTable(connection, database, _tableConfiguration);
                _localeTable = new LocaleTable(connection, database, _tableConfiguration);
                _valueTable = new ValueTable(connection, database, _tableConfiguration);
                _logTable = new LogTable(database, _tableConfiguration);
            }
        }
开发者ID:BackseatDevelopers,项目名称:BLocal,代码行数:18,代码来源:MSDBValueAndLogProvider.cs


注:本文中的Schema.Create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。