Example #1
0
        public void GenerateViews_generates_views_for_all_containers_that_contain_mappings()
        {
            var storageMappingItemCollection =
                CreateStorageMappingItemCollection(new[] { Ssdl, SchoolSsdl }, new[] { Csdl, SchoolCsdl }, new[] { Msl });

            // Add second container mapping without type mappings.
            var conceptualEntityContainer = storageMappingItemCollection.EdmItemCollection.GetItems <EntityContainer>()[1];
            var storeEntityContainer      = storageMappingItemCollection.StoreItemCollection.GetItems <EntityContainer>()[1];
            var storeEntitySet            = storeEntityContainer.EntitySets.First();

            var containerMapping = new EntityContainerMapping(
                conceptualEntityContainer, storeEntityContainer, storageMappingItemCollection, false);

            var entitySetMapping = new EntitySetMapping(storeEntitySet, containerMapping);

            containerMapping.AddSetMapping(entitySetMapping);

            containerMapping.SetReadOnly();
            storageMappingItemCollection.AddInternal(containerMapping);

            var errors = new List <EdmSchemaError>();
            var views  = storageMappingItemCollection.GenerateViews("AdventureWorksEntities3", "AdventureWorksModelStoreContainer", errors);

            Assert.Empty(errors);
            Assert.Equal(2, views.Count);

            errors = new List <EdmSchemaError>();
            views  = storageMappingItemCollection.GenerateViews("SchoolContainer", "SchoolStoreContainer", errors);

            Assert.Empty(errors);
            Assert.Equal(0, views.Count);
        }
Example #2
0
        public void SetReadOnly_is_called_on_child_mapping_items()
        {
            var conceptualContainer = new EntityContainer("C", DataSpace.CSpace);
            var storeContainer      = new EntityContainer("S", DataSpace.CSpace);
            var containerMapping    = new EntityContainerMapping(conceptualContainer, storeContainer, null, false);

            var entitySet
                = new EntitySet(
                      "ES", "S", "T", "Q",
                      new EntityType("ET", "N", DataSpace.SSpace));
            var entitySetMapping = new EntitySetMapping(entitySet, containerMapping);
            var associationSetMapping
                = new AssociationSetMapping(
                      new AssociationSet(
                          "AS",
                          new AssociationType("AT", "N", false, DataSpace.CSpace)),
                      entitySet);
            var functionImportMapping
                = new FunctionImportMappingFake(
                      new EdmFunction("FI", "N", DataSpace.CSpace),
                      new EdmFunction("TF", "N", DataSpace.SSpace));

            containerMapping.AddSetMapping(entitySetMapping);
            containerMapping.AddSetMapping(associationSetMapping);
            containerMapping.AddFunctionImportMapping(functionImportMapping);

            Assert.False(containerMapping.IsReadOnly);
            Assert.False(entitySetMapping.IsReadOnly);
            Assert.False(associationSetMapping.IsReadOnly);
            Assert.False(functionImportMapping.IsReadOnly);

            containerMapping.SetReadOnly();

            Assert.True(containerMapping.IsReadOnly);
            Assert.True(entitySetMapping.IsReadOnly);
            Assert.True(associationSetMapping.IsReadOnly);
            Assert.True(functionImportMapping.IsReadOnly);
        }