internal void MapToStoredProcedures(ModificationFunctionsConfiguration modificationFunctionsConfiguration)
        {
            DebugCheck.NotNull(modificationFunctionsConfiguration);

            if (_entityTypeConfiguration != null)
            {
                _entityTypeConfiguration().MapToStoredProcedures(modificationFunctionsConfiguration, allowOverride: false);
            }
        }
        public ConventionTypeConfiguration <T> MapToStoredProcedures(
            Action <ModificationFunctionsConfiguration <T> > modificationFunctionsConfigurationAction)
        {
            Check.NotNull(modificationFunctionsConfigurationAction, "modificationFunctionsConfigurationAction");

            var modificationFunctionMappingConfiguration = new ModificationFunctionsConfiguration <T>();

            modificationFunctionsConfigurationAction(modificationFunctionMappingConfiguration);

            _configuration.MapToStoredProcedures(modificationFunctionMappingConfiguration.Configuration);

            return(this);
        }
예제 #3
0
        public void MapToStoredProcedures_with_action_should_invoke_and_add_configuration()
        {
            var type        = typeof(LocalEntityType);
            var innerConfig = new EntityTypeConfiguration(type);
            var config      = new ConventionTypeConfiguration <LocalEntityType>(type, () => innerConfig, new ModelConfiguration());

            ModificationFunctionsConfiguration <LocalEntityType> configuration = null;

            config.MapToStoredProcedures(c => configuration = c);

            Assert.Same(
                configuration.Configuration,
                innerConfig.ModificationFunctionsConfiguration);
        }
        private ModificationFunctionsConfiguration(ModificationFunctionsConfiguration source)
        {
            DebugCheck.NotNull(source);

            if (source._insertModificationFunctionConfiguration != null)
            {
                _insertModificationFunctionConfiguration = source._insertModificationFunctionConfiguration.Clone();
            }

            if (source._updateModificationFunctionConfiguration != null)
            {
                _updateModificationFunctionConfiguration = source._updateModificationFunctionConfiguration.Clone();
            }

            if (source._deleteModificationFunctionConfiguration != null)
            {
                _deleteModificationFunctionConfiguration = source._deleteModificationFunctionConfiguration.Clone();
            }
        }
        private ModificationFunctionsConfiguration(ModificationFunctionsConfiguration source)
        {
            DebugCheck.NotNull(source);

            if (source._insertModificationFunctionConfiguration != null)
            {
                _insertModificationFunctionConfiguration = source._insertModificationFunctionConfiguration.Clone();
            }

            if (source._updateModificationFunctionConfiguration != null)
            {
                _updateModificationFunctionConfiguration = source._updateModificationFunctionConfiguration.Clone();
            }

            if (source._deleteModificationFunctionConfiguration != null)
            {
                _deleteModificationFunctionConfiguration = source._deleteModificationFunctionConfiguration.Clone();
            }
        }
        public bool IsCompatibleWith(ModificationFunctionsConfiguration other)
        {
            DebugCheck.NotNull(other);

            if ((_insertModificationFunctionConfiguration != null) &&
                (other._insertModificationFunctionConfiguration != null) &&
                !_insertModificationFunctionConfiguration.IsCompatibleWith(other._insertModificationFunctionConfiguration))
            {
                return(false);
            }

            if ((_deleteModificationFunctionConfiguration != null) &&
                (other._deleteModificationFunctionConfiguration != null) &&
                !_deleteModificationFunctionConfiguration.IsCompatibleWith(other._deleteModificationFunctionConfiguration))
            {
                return(false);
            }

            return(true);
        }
        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"));
        }
        public void Merge(ModificationFunctionsConfiguration modificationFunctionsConfiguration, bool allowOverride)
        {
            DebugCheck.NotNull(modificationFunctionsConfiguration);

            if (_insertModificationFunctionConfiguration == null)
            {
                _insertModificationFunctionConfiguration
                    = modificationFunctionsConfiguration.InsertModificationFunctionConfiguration;
            }
            else if (modificationFunctionsConfiguration.InsertModificationFunctionConfiguration != null)
            {
                _insertModificationFunctionConfiguration
                .Merge(modificationFunctionsConfiguration.InsertModificationFunctionConfiguration, allowOverride);
            }

            if (_updateModificationFunctionConfiguration == null)
            {
                _updateModificationFunctionConfiguration
                    = modificationFunctionsConfiguration.UpdateModificationFunctionConfiguration;
            }
            else if (modificationFunctionsConfiguration.UpdateModificationFunctionConfiguration != null)
            {
                _updateModificationFunctionConfiguration
                .Merge(modificationFunctionsConfiguration.UpdateModificationFunctionConfiguration, allowOverride);
            }

            if (_deleteModificationFunctionConfiguration == null)
            {
                _deleteModificationFunctionConfiguration
                    = modificationFunctionsConfiguration.DeleteModificationFunctionConfiguration;
            }
            else if (modificationFunctionsConfiguration.DeleteModificationFunctionConfiguration != null)
            {
                _deleteModificationFunctionConfiguration
                .Merge(modificationFunctionsConfiguration.DeleteModificationFunctionConfiguration, allowOverride);
            }
        }
        public bool IsCompatibleWith(ModificationFunctionsConfiguration other)
        {
            DebugCheck.NotNull(other);

            if ((_insertModificationFunctionConfiguration != null)
                && (other._insertModificationFunctionConfiguration != null)
                && !_insertModificationFunctionConfiguration.IsCompatibleWith(other._insertModificationFunctionConfiguration))
            {
                return false;
            }

            if ((_deleteModificationFunctionConfiguration != null)
                && (other._deleteModificationFunctionConfiguration != null)
                && !_deleteModificationFunctionConfiguration.IsCompatibleWith(other._deleteModificationFunctionConfiguration))
            {
                return false;
            }

            return true;
        }
        internal void MapToStoredProcedures(ModificationFunctionsConfiguration modificationFunctionsConfiguration)
        {
            DebugCheck.NotNull(modificationFunctionsConfiguration);

            if (_entityTypeConfiguration != null)
            {
                _entityTypeConfiguration().MapToStoredProcedures(modificationFunctionsConfiguration, allowOverride: false);
            }
        }