Ejemplo n.º 1
0
        public void Generate(EntityType entityType, DbDatabaseMapping databaseMapping)
        {
            if (entityType.Abstract)
            {
                return;
            }
            EntitySet                   entitySet        = databaseMapping.Model.GetEntitySet(entityType);
            EntitySetMapping            entitySetMapping = databaseMapping.GetEntitySetMapping(entitySet);
            List <ColumnMappingBuilder> list1            = ModificationFunctionMappingGenerator.GetColumnMappings(entityType, entitySetMapping).ToList <ColumnMappingBuilder>();
            List <Tuple <ModificationFunctionMemberPath, EdmProperty> > list2 = ModificationFunctionMappingGenerator.GetIndependentFkColumns(entityType, databaseMapping).ToList <Tuple <ModificationFunctionMemberPath, EdmProperty> >();
            ModificationFunctionMapping functionMapping1 = this.GenerateFunctionMapping(ModificationOperator.Insert, (EntitySetBase)entitySetMapping.EntitySet, (EntityTypeBase)entityType, databaseMapping, (IEnumerable <EdmProperty>)entityType.Properties, (IEnumerable <Tuple <ModificationFunctionMemberPath, EdmProperty> >)list2, (IList <ColumnMappingBuilder>)list1, entityType.Properties.Where <EdmProperty>((Func <EdmProperty, bool>)(p => p.HasStoreGeneratedPattern())), (string)null);
            ModificationFunctionMapping functionMapping2 = this.GenerateFunctionMapping(ModificationOperator.Update, (EntitySetBase)entitySetMapping.EntitySet, (EntityTypeBase)entityType, databaseMapping, (IEnumerable <EdmProperty>)entityType.Properties, (IEnumerable <Tuple <ModificationFunctionMemberPath, EdmProperty> >)list2, (IList <ColumnMappingBuilder>)list1, entityType.Properties.Where <EdmProperty>((Func <EdmProperty, bool>)(p =>
            {
                StoreGeneratedPattern?generatedPattern = p.GetStoreGeneratedPattern();
                if (generatedPattern.GetValueOrDefault() == StoreGeneratedPattern.Computed)
                {
                    return(generatedPattern.HasValue);
                }
                return(false);
            })), (string)null);
            ModificationFunctionMapping           functionMapping3            = this.GenerateFunctionMapping(ModificationOperator.Delete, (EntitySetBase)entitySetMapping.EntitySet, (EntityTypeBase)entityType, databaseMapping, (IEnumerable <EdmProperty>)entityType.Properties, (IEnumerable <Tuple <ModificationFunctionMemberPath, EdmProperty> >)list2, (IList <ColumnMappingBuilder>)list1, (IEnumerable <EdmProperty>)null, (string)null);
            EntityTypeModificationFunctionMapping modificationFunctionMapping = new EntityTypeModificationFunctionMapping(entityType, functionMapping3, functionMapping1, functionMapping2);

            entitySetMapping.AddModificationFunctionMapping(modificationFunctionMapping);
        }
Ejemplo n.º 2
0
        public void Generate(
            AssociationSetMapping associationSetMapping,
            DbDatabaseMapping databaseMapping)
        {
            List <Tuple <ModificationFunctionMemberPath, EdmProperty> > list = ModificationFunctionMappingGenerator.GetIndependentFkColumns(associationSetMapping).ToList <Tuple <ModificationFunctionMemberPath, EdmProperty> >();
            string functionNamePrefix = associationSetMapping.AssociationSet.ElementType.SourceEnd.GetEntityType().Name + associationSetMapping.AssociationSet.ElementType.TargetEnd.GetEntityType().Name;
            ModificationFunctionMapping functionMapping1 = this.GenerateFunctionMapping(ModificationOperator.Insert, (EntitySetBase)associationSetMapping.AssociationSet, (EntityTypeBase)associationSetMapping.AssociationSet.ElementType, databaseMapping, Enumerable.Empty <EdmProperty>(), (IEnumerable <Tuple <ModificationFunctionMemberPath, EdmProperty> >)list, (IList <ColumnMappingBuilder>) new ColumnMappingBuilder[0], (IEnumerable <EdmProperty>)null, functionNamePrefix);
            ModificationFunctionMapping functionMapping2 = this.GenerateFunctionMapping(ModificationOperator.Delete, (EntitySetBase)associationSetMapping.AssociationSet, (EntityTypeBase)associationSetMapping.AssociationSet.ElementType, databaseMapping, Enumerable.Empty <EdmProperty>(), (IEnumerable <Tuple <ModificationFunctionMemberPath, EdmProperty> >)list, (IList <ColumnMappingBuilder>) new ColumnMappingBuilder[0], (IEnumerable <EdmProperty>)null, functionNamePrefix);

            associationSetMapping.ModificationFunctionMapping = new AssociationSetModificationFunctionMapping(associationSetMapping.AssociationSet, functionMapping2, functionMapping1);
        }