/// <summary> /// Executes the query. /// </summary> /// <returns> /// The number of rows affected. /// </returns> public override int ExecuteNonQuery() { // Source: //// http://regexadvice.com/forums/thread/55175.aspx Regex regex = new Regex(@"CREATE *SCHEMA *\((.*)\)"); var matches = regex.Matches(this.CommandText.Trim()); if (matches.Count != 1) { throw new NotSupportedException(); } string keyString = matches[0].Groups[1].Value; DbSchemaKey key = DbSchemaKey.FromString(keyString); DbSchema schema = DbSchemaStore.GetDbSchema(key); DbContainer container = this.EffortConnection.DbContainer; container.Initialize(schema); return(0); }
/// <summary> /// Generates a data definition language (DDL0 script that creates schema objects /// (tables, primary keys, foreign keys) based on the contents of the /// <see cref="T:System.Data.Metadata.Edm.StoreItemCollection" /> parameter and /// targeted for the version of the database corresponding to the provider manifest /// token. /// </summary> /// <param name="providerManifestToken"> /// The provider manifest token identifying the target version. /// </param> /// <param name="storeItemCollection"> /// The structure of the database. /// </param> /// <returns> /// A DDL script that creates schema objects based on the contents of the /// <see cref="T:System.Data.Metadata.Edm.StoreItemCollection" /> parameter and /// targeted for the version of the database corresponding to the provider manifest /// token. /// </returns> protected override string DbCreateDatabaseScript( string providerManifestToken, StoreItemCollection storeItemCollection) { DbSchemaKey key = new DbSchemaKey(storeItemCollection); // Initialize schema DbSchemaStore.GetDbSchema(storeItemCollection, DbSchemaFactory.CreateDbSchema); return(string.Format("CREATE SCHEMA ({0})", key)); }
/// <summary> /// Returns a <see cref="DbSchema"/> object that is associated to the specified /// DbSchemaKey. /// </summary> /// <param name="schemaKey"> The DbSchemaKey object. </param> /// <returns> The DbSchema object. </returns> public static DbSchema GetDbSchema(DbSchemaKey schemaKey) { return store.Get(schemaKey); }