protected virtual void ConfigureColumn(EdmProperty column, EntityType table, DbProviderManifest providerManifest) { ConfigureColumnName(column, table); ConfigureAnnotations(column); if (!string.IsNullOrWhiteSpace(ColumnType)) { column.PrimitiveType = providerManifest.GetStoreTypeFromName(ColumnType); } if (ColumnOrder != null) { column.SetOrder(ColumnOrder.Value); } var storeType = providerManifest.GetStoreTypes() .SingleOrDefault(t => t.Name.Equals(column.TypeName, StringComparison.OrdinalIgnoreCase)); if (storeType != null) { storeType.FacetDescriptions.Each(f => Configure(column, f)); } column.SetConfiguration(this); }
protected virtual void ConfigureProperty(EdmProperty property) { 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; } } property.SetConfiguration(this); }
internal virtual void Configure( EdmProperty column, EntityType table, DbProviderManifest providerManifest, bool allowOverride = false, bool fillFromExistingConfiguration = false) { DebugCheck.NotNull(column); DebugCheck.NotNull(table); DebugCheck.NotNull(providerManifest); var existingConfiguration = column.GetConfiguration() as PrimitivePropertyConfiguration; if (existingConfiguration != null) { var overridable = column.GetAllowOverride(); string errorMessage; if ((existingConfiguration.OverridableConfigurationParts & OverridableConfigurationParts.OverridableInSSpace) != OverridableConfigurationParts.OverridableInSSpace && !overridable && !allowOverride && !fillFromExistingConfiguration && !existingConfiguration.IsCompatible(this, inCSpace: false, errorMessage: out errorMessage)) { throw Error.ConflictingColumnConfiguration(column.Name, table.Name, errorMessage); } FillFrom(existingConfiguration, inCSpace: false); } ConfigureColumnName(column, table); if (!string.IsNullOrWhiteSpace(ColumnType)) { column.PrimitiveType = providerManifest.GetStoreTypeFromName(ColumnType); } if (ColumnOrder != null) { column.SetOrder(ColumnOrder.Value); } var storeType = providerManifest.GetStoreTypes() .SingleOrDefault(t => t.Name.Equals(column.TypeName, StringComparison.OrdinalIgnoreCase)); if (storeType != null) { storeType.FacetDescriptions.Each(f => Configure(column, f)); } column.SetConfiguration(this); column.SetAllowOverride(allowOverride); }
protected virtual void ConfigureProperty(EdmProperty property) { if (this.IsNullable.HasValue) { property.Nullable = this.IsNullable.Value; } if (this.ConcurrencyMode.HasValue) { property.ConcurrencyMode = this.ConcurrencyMode.Value; } if (this.DatabaseGeneratedOption.HasValue) { property.SetStoreGeneratedPattern((StoreGeneratedPattern)this.DatabaseGeneratedOption.Value); if (this.DatabaseGeneratedOption.Value == System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedOption.Identity) { property.Nullable = false; } } property.SetConfiguration((object)this); }
protected virtual void ConfigureColumn( EdmProperty column, EntityType table, DbProviderManifest providerManifest) { this.ConfigureColumnName(column, table); this.ConfigureAnnotations(column); if (!string.IsNullOrWhiteSpace(this.ColumnType)) { column.PrimitiveType = providerManifest.GetStoreTypeFromName(this.ColumnType); } if (this.ColumnOrder.HasValue) { column.SetOrder(this.ColumnOrder.Value); } PrimitiveType primitiveType = providerManifest.GetStoreTypes().SingleOrDefault <PrimitiveType>((Func <PrimitiveType, bool>)(t => t.Name.Equals(column.TypeName, StringComparison.OrdinalIgnoreCase))); if (primitiveType != null) { primitiveType.FacetDescriptions.Each <FacetDescription>((Action <FacetDescription>)(f => this.Configure(column, f))); } column.SetConfiguration((object)this); }
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; } } }