private static void RemoveColumnMapping(StructuralTypeMapping structuralTypeMapping, IEnumerable <EdmProperty> propertyPath) { DebugCheck.NotNull(structuralTypeMapping); DebugCheck.NotNull(propertyPath); // Remove the target column mapping by walking down the mapping fragment // tree corresponding to the passed-in property path until we reach the scalar // mapping leaf node. On the way out remove any empty mappings. var propertyMapping = structuralTypeMapping .PropertyMappings .Single(pm => ReferenceEquals(pm.Property, propertyPath.First())); if (propertyMapping is ScalarPropertyMapping) { structuralTypeMapping.RemovePropertyMapping(propertyMapping); } else { var complexPropertyMapping = ((ComplexPropertyMapping)propertyMapping); var complexTypeMapping = complexPropertyMapping.TypeMappings.Single(); RemoveColumnMapping(complexTypeMapping, propertyPath.Skip(1)); if (!complexTypeMapping.PropertyMappings.Any()) { structuralTypeMapping.RemovePropertyMapping(complexPropertyMapping); } } }
private static void RemoveColumnMapping( StructuralTypeMapping structuralTypeMapping, IEnumerable <EdmProperty> propertyPath) { PropertyMapping propertyMapping = structuralTypeMapping.PropertyMappings.Single <PropertyMapping>((Func <PropertyMapping, bool>)(pm => object.ReferenceEquals((object)pm.Property, (object)propertyPath.First <EdmProperty>()))); if (propertyMapping is ScalarPropertyMapping) { structuralTypeMapping.RemovePropertyMapping(propertyMapping); } else { ComplexPropertyMapping complexPropertyMapping = (ComplexPropertyMapping)propertyMapping; ComplexTypeMapping complexTypeMapping = complexPropertyMapping.TypeMappings.Single <ComplexTypeMapping>(); MappingFragment.RemoveColumnMapping((StructuralTypeMapping)complexTypeMapping, propertyPath.Skip <EdmProperty>(1)); if (complexTypeMapping.PropertyMappings.Any <PropertyMapping>()) { return; } structuralTypeMapping.RemovePropertyMapping((PropertyMapping)complexPropertyMapping); } }
private static void RemoveColumnMapping(StructuralTypeMapping structuralTypeMapping, IEnumerable<EdmProperty> propertyPath) { DebugCheck.NotNull(structuralTypeMapping); DebugCheck.NotNull(propertyPath); // Remove the target column mapping by walking down the mapping fragment // tree corresponding to the passed-in property path until we reach the scalar // mapping leaf node. On the way out remove any empty mappings. var propertyMapping = structuralTypeMapping .PropertyMappings .Single(pm => ReferenceEquals(pm.Property, propertyPath.First())); if (propertyMapping is ScalarPropertyMapping) { structuralTypeMapping.RemovePropertyMapping(propertyMapping); } else { var complexPropertyMapping = ((ComplexPropertyMapping)propertyMapping); var complexTypeMapping = complexPropertyMapping.TypeMappings.Single(); RemoveColumnMapping(complexTypeMapping, propertyPath.Skip(1)); if (!complexTypeMapping.PropertyMappings.Any()) { structuralTypeMapping.RemovePropertyMapping(complexPropertyMapping); } } }