Esempio n. 1
0
        private void SynchronizeProperties(QueryEntityType entitySetBaseType, SerializableEntity serializedEntity, QueryEntityType entityType, QueryStructuralValue entity, IDictionary <EntityDataKey, QueryStructuralValue> existingEntityGraph)
        {
            var originalPropertyNames = entity.MemberNames.ToList();

            foreach (string streamName in entity.Type.Properties.Where(p => p.IsStream()).Select(p => p.Name))
            {
                originalPropertyNames.Remove(streamName);
            }

            var nonNavigationValues = new List <NamedValue>();

            // go throught the properties and recursively update any navigations, while saving the non-navigation properties for updating later
            foreach (var namedValue in serializedEntity.Properties)
            {
                NavigationProperty navProp = entityType.EntityType.AllNavigationProperties.Where(np => np.Name == namedValue.Name).SingleOrDefault();
                if (navProp != null)
                {
                    originalPropertyNames.Remove(namedValue.Name);
                    this.SynchronizeNavigationProperty(entitySetBaseType, entity, namedValue, existingEntityGraph);
                }
                else
                {
                    nonNavigationValues.Add(this.DataOracleConverter.Convert(namedValue));
                }
            }

            // synchronize the non-navigation values
            this.StructuralUpdater.UpdateValues(entity, nonNavigationValues);

            // Remove all structural properties that have been s
            string[] structualMemberPropertiesUpdated = this.GetTopLevelPropertyNames(nonNavigationValues);
            foreach (string propertyName in originalPropertyNames)
            {
                if (!structualMemberPropertiesUpdated.Contains(propertyName))
                {
                    entity.RemoveMember(propertyName);
                }
            }
        }