Exemplo n.º 1
0
        /// <summary>
        ///     Returns a value indicating whether a given database exists on the server and
        ///     whether schema objects contained in the storeItemCollection have been created.
        /// </summary>
        /// <param name="connection">
        ///     Connection to a database whose existence is verified by this method.
        /// </param>
        /// <param name="commandTimeout">
        ///     Execution timeout for any commands needed to determine the existence of the
        ///     database.
        /// </param>
        /// <param name="storeItemCollection">
        ///     The structure of the database whose existence is determined by this method.
        /// </param>
        /// <returns>
        ///     true if the database indicated by the connection and the
        ///     <paramref name="storeItemCollection" /> parameter exists.
        /// </returns>
        protected override bool DbDatabaseExists(
            DbConnection connection,
            int?commandTimeout,
            StoreItemCollection storeItemCollection)
        {
            return(Wrap(connection, x =>
            {
                DbContainer container = GetDbContainer(x);

                return container.IsInitialized(storeItemCollection);
            }));
        }
Exemplo n.º 2
0
        /// <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);
            });
        }