/// <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); }
public void DbSchema_CompoundKey() { StoreItemCollection ssdl = LoadSSDL("CompoundKey"); DbSchema schema = DbSchemaFactory.CreateDbSchema(ssdl); DbContainer container = new DbContainer(new DbContainerParameters()); container.Initialize(schema); }
/// <summary> /// Creates a database indicated by connection and creates schema objects (tables, /// primary keys, foreign keys) based on the contents of a /// <see cref="T:System.Data.Metadata.Edm.StoreItemCollection" />. /// </summary> /// <param name="connection"> /// Connection to a non-existent database that needs to be created and populated /// with the store objects indicated with the storeItemCollection parameter. /// </param> /// <param name="commandTimeout"> /// Execution timeout for any commands needed to create the database. /// </param> /// <param name="storeItemCollection"> /// The collection of all store items based on which the script should be created. /// </param> protected override void DbCreateDatabase( DbConnection connection, int?commandTimeout, StoreItemCollection storeItemCollection) { Wrap(connection, x => { DbContainer container = GetDbContainer(x); if (!container.IsInitialized(storeItemCollection)) { container.Initialize(storeItemCollection); } return(0); }); }