Beispiel #1
0
        public ConventionTypeConfiguration <T> MapToStoredProcedures(
            Action <ModificationStoredProceduresConfiguration <T> > modificationStoredProceduresConfigurationAction)
        {
            Check.NotNull <Action <ModificationStoredProceduresConfiguration <T> > >(modificationStoredProceduresConfigurationAction, nameof(modificationStoredProceduresConfigurationAction));
            ModificationStoredProceduresConfiguration <T> proceduresConfiguration = new ModificationStoredProceduresConfiguration <T>();

            modificationStoredProceduresConfigurationAction(proceduresConfiguration);
            this._configuration.MapToStoredProcedures(proceduresConfiguration.Configuration);
            return(this);
        }
        public ConventionTypeConfiguration <T> MapToStoredProcedures(
            Action <ModificationStoredProceduresConfiguration <T> > modificationStoredProceduresConfigurationAction)
        {
            Check.NotNull(modificationStoredProceduresConfigurationAction, "modificationStoredProceduresConfigurationAction");

            var modificationStoredProcedureMappingConfiguration = new ModificationStoredProceduresConfiguration <T>();

            modificationStoredProceduresConfigurationAction(modificationStoredProcedureMappingConfiguration);

            _configuration.MapToStoredProcedures(modificationStoredProcedureMappingConfiguration.Configuration);

            return(this);
        }
Beispiel #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());

            ModificationStoredProceduresConfiguration <LocalEntityType> configuration = null;

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

            Assert.Same(
                configuration.Configuration,
                innerConfig.ModificationStoredProceduresConfiguration);
        }
Beispiel #4
0
 private ModificationStoredProceduresConfiguration(
     ModificationStoredProceduresConfiguration source)
 {
     if (source._insertModificationStoredProcedureConfiguration != null)
     {
         this._insertModificationStoredProcedureConfiguration = source._insertModificationStoredProcedureConfiguration.Clone();
     }
     if (source._updateModificationStoredProcedureConfiguration != null)
     {
         this._updateModificationStoredProcedureConfiguration = source._updateModificationStoredProcedureConfiguration.Clone();
     }
     if (source._deleteModificationStoredProcedureConfiguration == null)
     {
         return;
     }
     this._deleteModificationStoredProcedureConfiguration = source._deleteModificationStoredProcedureConfiguration.Clone();
 }
        private ModificationStoredProceduresConfiguration(ModificationStoredProceduresConfiguration source)
        {
            DebugCheck.NotNull(source);

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

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

            if (source._deleteModificationStoredProcedureConfiguration != null)
            {
                _deleteModificationStoredProcedureConfiguration = source._deleteModificationStoredProcedureConfiguration.Clone();
            }
        }
Beispiel #6
0
        private ModificationStoredProceduresConfiguration(ModificationStoredProceduresConfiguration source)
        {
            DebugCheck.NotNull(source);

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

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

            if (source._deleteModificationStoredProcedureConfiguration != null)
            {
                _deleteModificationStoredProcedureConfiguration = source._deleteModificationStoredProcedureConfiguration.Clone();
            }
        }
Beispiel #7
0
        public bool IsCompatibleWith(ModificationStoredProceduresConfiguration other)
        {
            DebugCheck.NotNull(other);

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

            if ((_deleteModificationStoredProcedureConfiguration != null) &&
                (other._deleteModificationStoredProcedureConfiguration != null) &&
                !_deleteModificationStoredProcedureConfiguration.IsCompatibleWith(other._deleteModificationStoredProcedureConfiguration))
            {
                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 ModificationStoredProceduresConfiguration();

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

            modificationFunctionsConfiguration.Insert(modificationFunctionConfiguration);

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

            var model = new EdmModel(DataSpace.CSpace);

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

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

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

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

            modelConfiguration.Configure(databaseMapping, ProviderRegistry.Sql2008_ProviderManifest);

            Assert.True(databaseMapping.Database.Functions.Any(f => f.StoreFunctionNameAttribute == "A_Insert"));
            Assert.True(databaseMapping.Database.Functions.Any(f => f.StoreFunctionNameAttribute == "A_Insert1"));
        }
Beispiel #9
0
 private static void UniquifyFunctionNames(DbDatabaseMapping databaseMapping)
 {
     foreach (EntityTypeModificationFunctionMapping modificationFunctionMapping in databaseMapping.GetEntitySetMappings().SelectMany <EntitySetMapping, EntityTypeModificationFunctionMapping>((Func <EntitySetMapping, IEnumerable <EntityTypeModificationFunctionMapping> >)(esm => (IEnumerable <EntityTypeModificationFunctionMapping>)esm.ModificationFunctionMappings)))
     {
         EntityTypeConfiguration configuration = (EntityTypeConfiguration)modificationFunctionMapping.EntityType.GetConfiguration();
         if (configuration.ModificationStoredProceduresConfiguration != null)
         {
             ModificationStoredProceduresConfiguration proceduresConfiguration = configuration.ModificationStoredProceduresConfiguration;
             System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.UniquifyFunctionName(databaseMapping, proceduresConfiguration.InsertModificationStoredProcedureConfiguration, modificationFunctionMapping.InsertFunctionMapping);
             System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.UniquifyFunctionName(databaseMapping, proceduresConfiguration.UpdateModificationStoredProcedureConfiguration, modificationFunctionMapping.UpdateFunctionMapping);
             System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.UniquifyFunctionName(databaseMapping, proceduresConfiguration.DeleteModificationStoredProcedureConfiguration, modificationFunctionMapping.DeleteFunctionMapping);
         }
     }
     foreach (AssociationSetModificationFunctionMapping modificationFunctionMapping in databaseMapping.GetAssociationSetMappings().Select <AssociationSetMapping, AssociationSetModificationFunctionMapping>((Func <AssociationSetMapping, AssociationSetModificationFunctionMapping>)(asm => asm.ModificationFunctionMapping)).Where <AssociationSetModificationFunctionMapping>((Func <AssociationSetModificationFunctionMapping, bool>)(asm => asm != null)))
     {
         NavigationPropertyConfiguration configuration = (NavigationPropertyConfiguration)modificationFunctionMapping.AssociationSet.ElementType.GetConfiguration();
         if (configuration.ModificationStoredProceduresConfiguration != null)
         {
             System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.UniquifyFunctionName(databaseMapping, configuration.ModificationStoredProceduresConfiguration.InsertModificationStoredProcedureConfiguration, modificationFunctionMapping.InsertFunctionMapping);
             System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.UniquifyFunctionName(databaseMapping, configuration.ModificationStoredProceduresConfiguration.DeleteModificationStoredProcedureConfiguration, modificationFunctionMapping.DeleteFunctionMapping);
         }
     }
 }
Beispiel #10
0
        public void Merge(ModificationStoredProceduresConfiguration modificationStoredProceduresConfiguration, bool allowOverride)
        {
            DebugCheck.NotNull(modificationStoredProceduresConfiguration);

            if (_insertModificationStoredProcedureConfiguration == null)
            {
                _insertModificationStoredProcedureConfiguration
                    = modificationStoredProceduresConfiguration.InsertModificationStoredProcedureConfiguration;
            }
            else if (modificationStoredProceduresConfiguration.InsertModificationStoredProcedureConfiguration != null)
            {
                _insertModificationStoredProcedureConfiguration
                .Merge(modificationStoredProceduresConfiguration.InsertModificationStoredProcedureConfiguration, allowOverride);
            }

            if (_updateModificationStoredProcedureConfiguration == null)
            {
                _updateModificationStoredProcedureConfiguration
                    = modificationStoredProceduresConfiguration.UpdateModificationStoredProcedureConfiguration;
            }
            else if (modificationStoredProceduresConfiguration.UpdateModificationStoredProcedureConfiguration != null)
            {
                _updateModificationStoredProcedureConfiguration
                .Merge(modificationStoredProceduresConfiguration.UpdateModificationStoredProcedureConfiguration, allowOverride);
            }

            if (_deleteModificationStoredProcedureConfiguration == null)
            {
                _deleteModificationStoredProcedureConfiguration
                    = modificationStoredProceduresConfiguration.DeleteModificationStoredProcedureConfiguration;
            }
            else if (modificationStoredProceduresConfiguration.DeleteModificationStoredProcedureConfiguration != null)
            {
                _deleteModificationStoredProcedureConfiguration
                .Merge(modificationStoredProceduresConfiguration.DeleteModificationStoredProcedureConfiguration, allowOverride);
            }
        }
Beispiel #11
0
 public bool IsCompatibleWith(ModificationStoredProceduresConfiguration other)
 {
     return((this._insertModificationStoredProcedureConfiguration == null || other._insertModificationStoredProcedureConfiguration == null || this._insertModificationStoredProcedureConfiguration.IsCompatibleWith(other._insertModificationStoredProcedureConfiguration)) && (this._deleteModificationStoredProcedureConfiguration == null || other._deleteModificationStoredProcedureConfiguration == null || this._deleteModificationStoredProcedureConfiguration.IsCompatibleWith(other._deleteModificationStoredProcedureConfiguration)));
 }
        internal void MapToStoredProcedures(ModificationStoredProceduresConfiguration modificationStoredProceduresConfiguration)
        {
            DebugCheck.NotNull(modificationStoredProceduresConfiguration);

            if (_entityTypeConfiguration != null)
            {
                _entityTypeConfiguration().MapToStoredProcedures(modificationStoredProceduresConfiguration, allowOverride: false);
            }
        }
        public void Merge(ModificationStoredProceduresConfiguration modificationStoredProceduresConfiguration, bool allowOverride)
        {
            DebugCheck.NotNull(modificationStoredProceduresConfiguration);

            if (_insertModificationStoredProcedureConfiguration == null)
            {
                _insertModificationStoredProcedureConfiguration
                    = modificationStoredProceduresConfiguration.InsertModificationStoredProcedureConfiguration;
            }
            else if (modificationStoredProceduresConfiguration.InsertModificationStoredProcedureConfiguration != null)
            {
                _insertModificationStoredProcedureConfiguration
                    .Merge(modificationStoredProceduresConfiguration.InsertModificationStoredProcedureConfiguration, allowOverride);
            }

            if (_updateModificationStoredProcedureConfiguration == null)
            {
                _updateModificationStoredProcedureConfiguration
                    = modificationStoredProceduresConfiguration.UpdateModificationStoredProcedureConfiguration;
            }
            else if (modificationStoredProceduresConfiguration.UpdateModificationStoredProcedureConfiguration != null)
            {
                _updateModificationStoredProcedureConfiguration
                    .Merge(modificationStoredProceduresConfiguration.UpdateModificationStoredProcedureConfiguration, allowOverride);
            }

            if (_deleteModificationStoredProcedureConfiguration == null)
            {
                _deleteModificationStoredProcedureConfiguration
                    = modificationStoredProceduresConfiguration.DeleteModificationStoredProcedureConfiguration;
            }
            else if (modificationStoredProceduresConfiguration.DeleteModificationStoredProcedureConfiguration != null)
            {
                _deleteModificationStoredProcedureConfiguration
                    .Merge(modificationStoredProceduresConfiguration.DeleteModificationStoredProcedureConfiguration, allowOverride);
            }
        }
        public bool IsCompatibleWith(ModificationStoredProceduresConfiguration other)
        {
            DebugCheck.NotNull(other);

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

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

            return true;
        }