예제 #1
0
        public LightweightModificationFunctionsConfiguration Insert(
            Action <LightweightInsertModificationFunctionConfiguration> modificationFunctionConfigurationAction)
        {
            Check.NotNull(modificationFunctionConfigurationAction, "modificationFunctionConfigurationAction");

            var modificationFunctionConfiguration
                = new LightweightInsertModificationFunctionConfiguration(_type);

            modificationFunctionConfigurationAction(modificationFunctionConfiguration);

            _configuration.Insert(modificationFunctionConfiguration.Configuration);

            return(this);
        }
예제 #2
0
        public ModificationFunctionsConfiguration <TEntityType> Insert(
            Action <InsertModificationFunctionConfiguration <TEntityType> > modificationFunctionConfigurationAction)
        {
            Check.NotNull(modificationFunctionConfigurationAction, "modificationFunctionConfigurationAction");

            var modificationFunctionConfiguration
                = new InsertModificationFunctionConfiguration <TEntityType>();

            modificationFunctionConfigurationAction(modificationFunctionConfiguration);

            _configuration.Insert(modificationFunctionConfiguration.Configuration);

            return(this);
        }
        public void Configure_should_uniquify_unconfigured_function_names()
        {
            var modelConfiguration = new ModelConfiguration();

            var typeA = new MockType("A");
            var typeB = new MockType("B");

            modelConfiguration.Entity(typeA).MapToStoredProcedures();

            var modificationFunctionsConfiguration
                = new ModificationFunctionsConfiguration();

            var modificationFunctionConfiguration = new ModificationFunctionConfiguration();
            modificationFunctionConfiguration.HasName("A_Insert");

            modificationFunctionsConfiguration.Insert(modificationFunctionConfiguration);

            modelConfiguration.Entity(typeB).MapToStoredProcedures(modificationFunctionsConfiguration);

            var model = new EdmModel(DataSpace.CSpace);

            var entityA = model.AddEntityType("A");
            entityA.Annotations.SetClrType(typeA);
            entityA.SetConfiguration(modelConfiguration.Entity(typeA));

            var entityB = model.AddEntityType("B");
            entityB.Annotations.SetClrType(typeB);
            entityB.SetConfiguration(modelConfiguration.Entity(typeB));

            model.AddEntitySet("AS", entityA);
            model.AddEntitySet("BS", entityB);

            var databaseMapping
                = new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderManifest)
                    .Generate(model);

            modelConfiguration.Configure(databaseMapping, ProviderRegistry.Sql2008_ProviderManifest);

            Assert.True(databaseMapping.Database.Functions.Any(f => f.Name == "A_Insert"));
            Assert.True(databaseMapping.Database.Functions.Any(f => f.Name == "A_Insert1"));
        }