Пример #1
0
        /// <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);
        }
Пример #2
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));
        }
Пример #3
0
        public void Initialize(StoreItemCollection edmStoreSchema)
        {
            if (this.IsInitialized(edmStoreSchema))
            {
                return;
            }

            DbSchema schema =
                DbSchemaStore.GetDbSchema(
                    edmStoreSchema,
                    sic => DbSchemaFactory.CreateDbSchema(sic));

            this.Initialize(schema);
        }