public void DeleteDatabase(ICommerceDatabase database)
        {
            Require.NotNull(database, "database");

            var dbContext           = ((CommerceDatabase)database).DbContext;
            var objectContext       = ToObjectContext(dbContext);
            var storeItemCollection = (StoreItemCollection)objectContext.MetadataWorkspace.GetItemCollection(DataSpace.SSpace);
            var script = SqlScripts.DropObjects(storeItemCollection);

            dbContext.Database.ExecuteSqlCommand(script);
        }
Ejemplo n.º 2
0
        public static string DropObjects(StoreItemCollection itemCollection)
        {
            var builder = new SqlScripts();

            foreach (var container in itemCollection.GetItems<EntityContainer>())
            {
                var entitySets = container.BaseEntitySets.OfType<EntitySet>().OrderBy(s => s.Name);

                foreach (var associationSet in container.BaseEntitySets.OfType<AssociationSet>().OrderBy(s => s.Name))
                {
                    builder.AppendDropForeignKeys(associationSet);
                }

                foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>().OrderBy(s => s.Name))
                {
                    builder.AppendDropTable(entitySet);
                }
            }

            return builder.GetCommandText();
        }
Ejemplo n.º 3
0
        public static string DropObjects(StoreItemCollection itemCollection)
        {
            var builder = new SqlScripts();

            foreach (var container in itemCollection.GetItems <EntityContainer>())
            {
                var entitySets = container.BaseEntitySets.OfType <EntitySet>().OrderBy(s => s.Name);

                foreach (var associationSet in container.BaseEntitySets.OfType <AssociationSet>().OrderBy(s => s.Name))
                {
                    builder.AppendDropForeignKeys(associationSet);
                }

                foreach (var entitySet in container.BaseEntitySets.OfType <EntitySet>().OrderBy(s => s.Name))
                {
                    builder.AppendDropTable(entitySet);
                }
            }

            return(builder.GetCommandText());
        }