public void GetStoreGeneratedPattern_should_return_null_when_not_set() { var property = new EdmProperty().AsPrimitive(); var storeGeneratedPattern = property.GetStoreGeneratedPattern(); Assert.Null(storeGeneratedPattern); }
public void SetStoreGeneratedPattern_should_create_annotation_and_add_to_property_facets() { var property = new EdmProperty().AsPrimitive(); property.SetStoreGeneratedPattern(DbStoreGeneratedPattern.Computed); var storeGeneratedPattern = property.GetStoreGeneratedPattern(); Assert.NotNull(storeGeneratedPattern); Assert.Equal(DbStoreGeneratedPattern.Computed, storeGeneratedPattern); }
public void SetStoreGeneratedPattern_should_update_existing_annotation() { var property = new EdmProperty().AsPrimitive(); property.SetStoreGeneratedPattern(DbStoreGeneratedPattern.Computed); property.SetStoreGeneratedPattern(DbStoreGeneratedPattern.None); var storeGeneratedPattern = property.GetStoreGeneratedPattern(); Assert.NotNull(storeGeneratedPattern); Assert.Equal(DbStoreGeneratedPattern.None, storeGeneratedPattern); }
public void Configure_should_update_IsRowVersion() { var configuration = CreateConfiguration(); configuration.IsRowVersion = true; var property = new EdmProperty().AsPrimitive(); configuration.Configure(property); Assert.Equal(8, property.PropertyType.PrimitiveTypeFacets.MaxLength); Assert.Equal(false, property.PropertyType.IsNullable); Assert.Equal(EdmConcurrencyMode.Fixed, property.ConcurrencyMode); Assert.Equal(DbStoreGeneratedPattern.Computed, property.GetStoreGeneratedPattern()); var edmPropertyMapping = new DbEdmPropertyMapping { Column = new DbTableColumnMetadata { Facets = new DbPrimitiveTypeFacets() } }; configuration.Configure(new[] { Tuple.Create(edmPropertyMapping, new DbTableMetadata()) }, ProviderRegistry.Sql2008_ProviderManifest); Assert.Equal("rowversion", edmPropertyMapping.Column.TypeName); }
protected void MapTableColumn( EdmProperty property, DbTableColumnMetadata tableColumnMetadata, bool isInstancePropertyOnDerivedType, bool isKeyProperty = false) { Contract.Requires(property != null); Contract.Requires(tableColumnMetadata != null); var storeTypeUsage = _providerManifest.GetStoreType(GetEdmTypeUsage(property.PropertyType)); tableColumnMetadata.TypeName = storeTypeUsage.EdmType.Name; tableColumnMetadata.IsPrimaryKeyColumn = isKeyProperty; if (isInstancePropertyOnDerivedType) { tableColumnMetadata.IsNullable = true; } else if (property.PropertyType.IsNullable != null) { tableColumnMetadata.IsNullable = property.PropertyType.IsNullable.Value; } if (tableColumnMetadata.IsPrimaryKeyColumn) { tableColumnMetadata.IsNullable = false; } var storeGeneratedPattern = property.GetStoreGeneratedPattern(); if (storeGeneratedPattern != null) { tableColumnMetadata.StoreGeneratedPattern = storeGeneratedPattern.Value; } MapPrimitivePropertyFacets( property.PropertyType.PrimitiveTypeFacets, tableColumnMetadata.Facets, storeTypeUsage); }
public void Configure_should_update_model_property_store_generated_pattern() { var configuration = CreateConfiguration(); configuration.DatabaseGeneratedOption = DatabaseGeneratedOption.Identity; var property = new EdmProperty().AsPrimitive(); configuration.Configure(property); Assert.Equal(DbStoreGeneratedPattern.Identity, property.GetStoreGeneratedPattern()); Assert.Equal(false, property.PropertyType.IsNullable); }