Exemplo n.º 1
0
        private static void ProcessModifiedEntity(List <ModifiedObjectMetadata> modifyObjectsMetada, InternalEntityEntry entityEntry, ChangeTracker changeTracker)
        {
            ModifiedObjectMetadata      modifyObjectMetada = GetOrCreateMetaData(modifyObjectsMetada, entityEntry.Entity);
            IEnumerable <PropertyEntry> properties         = entityEntry.GetProperties();

            ProcessProperties(entityEntry.Entity, modifyObjectMetada, properties);
            ProcessNavigations(entityEntry, modifyObjectsMetada, modifyObjectMetada, properties, changeTracker);
        }
Exemplo n.º 2
0
        private static void ProcessAddedEntity(List <ModifiedObjectMetadata> modifiedObjectsMetadataList, InternalEntityEntry entityEntry, ChangeTracker changeTracker)
        {
            IEnumerable <IForeignKey> foreignKeys = entityEntry.EntityType.GetForeignKeys();
            // ModifiedObjectMetadata modifyObjectMetada = GetOrCreateMetaData(modifiedObjectsMetadataList, entityEntry.Entity);
            IEnumerable <PropertyEntry> properties = entityEntry.GetProperties();

            foreach (IForeignKey foreignKey in foreignKeys)
            {
                for (int i = 0; i < foreignKey.Properties.Count(); i++)
                {
                    PropertyEntry propertyEntry = properties.First(p => p.Metadata.Name == foreignKey.Properties[0].Name);
                    if (propertyEntry.CurrentValue != null && propertyEntry.CurrentValue.Equals(null))
                    {
                        continue;
                    }
                    InternalEntityEntry principaEntityEntryCurrentValue = changeTracker.GetPrincipalEntityEntryCurrentValue(entityEntry, foreignKey);
                    if (principaEntityEntryCurrentValue != null && principaEntityEntryCurrentValue.EntityState != EntityState.Added)
                    {
                        ProcessPrincipalEntity(entityEntry, modifiedObjectsMetadataList, foreignKey, principaEntityEntryCurrentValue);
                    }
                }
            }
        }