public IEnumerable <ModificationFunctionParameterBinding> Generate( ModificationOperator modificationOperator, IEnumerable <EdmProperty> properties, IList <ColumnMappingBuilder> columnMappings, IList <EdmProperty> propertyPath, bool useOriginalValues = false) { foreach (EdmProperty property1 in properties) { EdmProperty property = property1; if (property.IsComplexType && propertyPath.Any <EdmProperty>((Func <EdmProperty, bool>)(p => { if (p.IsComplexType) { return(p.ComplexType == property.ComplexType); } return(false); }))) { throw Error.CircularComplexTypeHierarchy(); } propertyPath.Add(property); if (property.IsComplexType) { foreach (ModificationFunctionParameterBinding parameterBinding in this.Generate(modificationOperator, (IEnumerable <EdmProperty>)property.ComplexType.Properties, columnMappings, propertyPath, useOriginalValues)) { yield return(parameterBinding); } } else { StoreGeneratedPattern?generatedPattern1 = property.GetStoreGeneratedPattern(); if ((generatedPattern1.GetValueOrDefault() != StoreGeneratedPattern.Identity ? 1 : (!generatedPattern1.HasValue ? 1 : 0)) != 0 || modificationOperator != ModificationOperator.Insert) { EdmProperty columnProperty = columnMappings.First <ColumnMappingBuilder>((Func <ColumnMappingBuilder, bool>)(cm => cm.PropertyPath.SequenceEqual <EdmProperty>((IEnumerable <EdmProperty>)propertyPath))).ColumnProperty; StoreGeneratedPattern?generatedPattern2 = property.GetStoreGeneratedPattern(); if ((generatedPattern2.GetValueOrDefault() != StoreGeneratedPattern.Computed ? 1 : (!generatedPattern2.HasValue ? 1 : 0)) != 0 && (modificationOperator != ModificationOperator.Delete || property.IsKeyMember)) { yield return(new ModificationFunctionParameterBinding(new FunctionParameter(columnProperty.Name, columnProperty.TypeUsage, ParameterMode.In), new ModificationFunctionMemberPath((IEnumerable <EdmMember>)propertyPath, (AssociationSet)null), !useOriginalValues)); } if (modificationOperator != ModificationOperator.Insert && property.ConcurrencyMode == ConcurrencyMode.Fixed) { yield return(new ModificationFunctionParameterBinding(new FunctionParameter(columnProperty.Name + "_Original", columnProperty.TypeUsage, ParameterMode.In), new ModificationFunctionMemberPath((IEnumerable <EdmMember>)propertyPath, (AssociationSet)null), false)); } } } propertyPath.Remove(property); } }
protected EdmProperty MapTableColumn( EdmProperty property, string columnName, bool isInstancePropertyOnDerivedType) { DebugCheck.NotNull(property); DebugCheck.NotEmpty(columnName); var underlyingTypeUsage = TypeUsage.Create(property.UnderlyingPrimitiveType, property.TypeUsage.Facets); var storeTypeUsage = _providerManifest.GetStoreType(underlyingTypeUsage); var tableColumnMetadata = new EdmProperty(columnName, storeTypeUsage) { Nullable = isInstancePropertyOnDerivedType || property.Nullable }; if (tableColumnMetadata.IsPrimaryKeyColumn) { tableColumnMetadata.Nullable = false; } var storeGeneratedPattern = property.GetStoreGeneratedPattern(); if (storeGeneratedPattern != null) { tableColumnMetadata.StoreGeneratedPattern = storeGeneratedPattern.Value; } MapPrimitivePropertyFacets(property, tableColumnMetadata, storeTypeUsage); return(tableColumnMetadata); }
/// <inheritdoc /> public virtual void Apply(EntityType item, DbModel model) { Check.NotNull <EntityType>(item, nameof(item)); Check.NotNull <DbModel>(model, nameof(model)); if (item.BaseType != null || item.KeyProperties.Count != 1 || item.DeclaredProperties.Select(p => new { p = p, sgp = p.GetStoreGeneratedPattern() }).Where(_param0 => { if (!_param0.sgp.HasValue) { return(false); } StoreGeneratedPattern?sgp = _param0.sgp; if (sgp.GetValueOrDefault() == StoreGeneratedPattern.Identity) { return(sgp.HasValue); } return(false); }).Select(_param0 => _param0.sgp).Any <StoreGeneratedPattern?>()) { return; } EdmProperty property = item.KeyProperties.Single <EdmProperty>(); if (property.GetStoreGeneratedPattern().HasValue || property.PrimitiveType == null || !StoreGeneratedIdentityKeyConvention._applicableTypes.Contains <PrimitiveTypeKind>(property.PrimitiveType.PrimitiveTypeKind) || (model.ConceptualModel.AssociationTypes.Any <AssociationType>((Func <AssociationType, bool>)(a => StoreGeneratedIdentityKeyConvention.IsNonTableSplittingForeignKey(a, property))) || StoreGeneratedIdentityKeyConvention.ParentOfTpc(item, model.ConceptualModel))) { return; } property.SetStoreGeneratedPattern(StoreGeneratedPattern.Identity); }
public static bool HasStoreGeneratedPattern(this EdmProperty property) { DebugCheck.NotNull(property); var storeGeneratedPattern = property.GetStoreGeneratedPattern(); return(storeGeneratedPattern != null && storeGeneratedPattern != StoreGeneratedPattern.None); }
public static bool HasStoreGeneratedPattern(this EdmProperty property) { StoreGeneratedPattern?generatedPattern = property.GetStoreGeneratedPattern(); if (!generatedPattern.HasValue) { return(false); } StoreGeneratedPattern?nullable = generatedPattern; if (nullable.GetValueOrDefault() == StoreGeneratedPattern.None) { return(!nullable.HasValue); } return(true); }
protected EdmProperty MapTableColumn( EdmProperty property, string columnName, bool isInstancePropertyOnDerivedType) { TypeUsage storeType = this._providerManifest.GetStoreType(TypeUsage.Create((EdmType)property.UnderlyingPrimitiveType, (IEnumerable <Facet>)property.TypeUsage.Facets)); EdmProperty column = new EdmProperty(columnName, storeType) { Nullable = isInstancePropertyOnDerivedType || property.Nullable }; if (column.IsPrimaryKeyColumn) { column.Nullable = false; } StoreGeneratedPattern?generatedPattern = property.GetStoreGeneratedPattern(); if (generatedPattern.HasValue) { column.StoreGeneratedPattern = generatedPattern.Value; } StructuralTypeMappingGenerator.MapPrimitivePropertyFacets(property, column, storeType); return(column); }