internal virtual void Configure(EdmProperty property) { this.Clone().MergeWithExistingConfiguration(property, (Func <string, Exception>)(errorMessage => { PropertyInfo clrPropertyInfo = property.GetClrPropertyInfo(); return(Error.ConflictingPropertyConfiguration((object)property.Name, clrPropertyInfo == (PropertyInfo)null ? (object)string.Empty : (object)ObjectContextTypeCache.GetObjectType(clrPropertyInfo.DeclaringType).FullNameWithNesting(), (object)errorMessage)); }), true, false).ConfigureProperty(property); }
internal virtual void Configure(EdmProperty property) { DebugCheck.NotNull(property); Debug.Assert(property.TypeUsage != null); var clone = Clone(); var mergedConfiguration = clone.MergeWithExistingConfiguration( property, errorMessage => { var propertyInfo = property.GetClrPropertyInfo(); var declaringTypeName = propertyInfo == null ? string.Empty : ObjectContextTypeCache.GetObjectType(propertyInfo.DeclaringType). FullNameWithNesting(); return(Error.ConflictingPropertyConfiguration(property.Name, declaringTypeName, errorMessage)); }, inCSpace: true, fillFromExistingConfiguration: false); mergedConfiguration.ConfigureProperty(property); }
internal virtual void Configure(EdmProperty property) { DebugCheck.NotNull(property); Debug.Assert(property.TypeUsage != null); var existingConfiguration = property.GetConfiguration() as PrimitivePropertyConfiguration; if (existingConfiguration != null) { string errorMessage; if ((existingConfiguration.OverridableConfigurationParts & OverridableConfigurationParts.OverridableInCSpace) != OverridableConfigurationParts.OverridableInCSpace && !existingConfiguration.IsCompatible(this, inCSpace: true, errorMessage: out errorMessage)) { var propertyInfo = property.GetClrPropertyInfo(); var declaringTypeName = propertyInfo == null ? string.Empty : ObjectContextTypeCache.GetObjectType(propertyInfo.DeclaringType). FullNameWithNesting(); throw Error.ConflictingPropertyConfiguration(property.Name, declaringTypeName, errorMessage); } // Choose the more derived type for the merged configuration PrimitivePropertyConfiguration mergedConfiguration; if (existingConfiguration.GetType().IsAssignableFrom(GetType())) { mergedConfiguration = (PrimitivePropertyConfiguration)MemberwiseClone(); } else { mergedConfiguration = (PrimitivePropertyConfiguration)existingConfiguration.MemberwiseClone(); mergedConfiguration.CopyFrom(this); } mergedConfiguration.FillFrom(existingConfiguration, inCSpace: true); property.SetConfiguration(mergedConfiguration); } else { property.SetConfiguration(this); } if (IsNullable != null) { property.Nullable = IsNullable.Value; } if (ConcurrencyMode != null) { property.ConcurrencyMode = ConcurrencyMode.Value; } if (DatabaseGeneratedOption != null) { property.SetStoreGeneratedPattern((StoreGeneratedPattern)DatabaseGeneratedOption.Value); if (DatabaseGeneratedOption.Value == ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity) { property.Nullable = false; } } }