本文整理汇总了C#中System.Data.Entity.Edm.EdmProperty类的典型用法代码示例。如果您正苦于以下问题:C# EdmProperty类的具体用法?C# EdmProperty怎么用?C# EdmProperty使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmProperty类属于System.Data.Entity.Edm命名空间,在下文中一共展示了EdmProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply_should_discover_for_self_reference
public void Apply_should_discover_for_self_reference()
{
var associationType = new EdmAssociationType().Initialize();
associationType.SourceEnd.EndKind = EdmAssociationEndKind.Optional;
associationType.SourceEnd.EntityType = new EdmEntityType();
associationType.TargetEnd.EndKind = EdmAssociationEndKind.Many;
associationType.TargetEnd.EntityType = associationType.SourceEnd.EntityType;
var pkProperty = new EdmProperty().AsPrimitive();
associationType.SourceEnd.EntityType.DeclaredKeyProperties.Add(pkProperty);
var fkProperty = new EdmProperty().AsPrimitive();
associationType.TargetEnd.EntityType.DeclaredProperties.Add(fkProperty);
associationType.TargetEnd.EntityType.AddNavigationProperty("Nav", associationType).ResultEnd = associationType.SourceEnd;
associationType.TargetEnd.EntityType.AddNavigationProperty("Foos", associationType);
// Foo.Id == Foo.NavId
pkProperty.Name = "Id";
fkProperty.Name = "NavId";
((IEdmConvention<EdmAssociationType>)new NavigationPropertyNameForeignKeyDiscoveryConvention())
.Apply(associationType, new EdmModel().Initialize());
Assert.NotNull(associationType.Constraint);
Assert.Same(associationType.TargetEnd, associationType.Constraint.DependentEnd);
Assert.Equal("NavId", associationType.Constraint.DependentProperties.Single().Name);
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:29,代码来源:NavigationPropertyNameForeignKeyDiscoveryConventionTests.cs
示例2: AsPrimitive_should_create_property_type_and_facets
public void AsPrimitive_should_create_property_type_and_facets()
{
var property = new EdmProperty().AsPrimitive();
Assert.NotNull(property.PropertyType);
Assert.NotNull(property.PropertyType.PrimitiveTypeFacets);
}
示例3: AsEnum_should_create_property_type
public void AsEnum_should_create_property_type()
{
var property = new EdmProperty().AsEnum(new EdmEnumType());
Assert.NotNull(property.PropertyType);
Assert.True(property.PropertyType.IsEnumType);
}
示例4: Apply_should_discover_composite_matching_foreign_keys
public void Apply_should_discover_composite_matching_foreign_keys()
{
var associationType = CreateAssociationType();
var pkProperty1 = new EdmProperty().AsPrimitive();
var pkProperty2 = new EdmProperty().AsPrimitive();
associationType.SourceEnd.EntityType.DeclaredKeyProperties.Add(pkProperty1);
associationType.SourceEnd.EntityType.DeclaredKeyProperties.Add(pkProperty2);
var fkProperty1 = new EdmProperty().AsPrimitive();
var fkProperty2 = new EdmProperty().AsPrimitive();
associationType.TargetEnd.EntityType.DeclaredProperties.Add(fkProperty1);
associationType.TargetEnd.EntityType.DeclaredProperties.Add(fkProperty2);
// Foo.PId1 == Bar.PId1 && Foo.PId2 == Bar.PId2
pkProperty1.Name = "PId1";
pkProperty2.Name = "PId2";
fkProperty1.Name = "PId1";
fkProperty2.Name = "PId2";
((IEdmConvention<EdmAssociationType>)new PrimaryKeyNameForeignKeyDiscoveryConvention())
.Apply(associationType, new EdmModel().Initialize());
Assert.NotNull(associationType.Constraint);
Assert.Same(associationType.TargetEnd, associationType.Constraint.DependentEnd);
Assert.Equal(2, associationType.Constraint.DependentProperties.Count());
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:27,代码来源:PrimaryKeyNameForeignKeyDiscoveryConventionTests.cs
示例5: Can_get_and_set_configuration_annotation
public void Can_get_and_set_configuration_annotation()
{
var property = new EdmProperty();
property.SetConfiguration(42);
Assert.Equal(42, property.GetConfiguration());
}
示例6: AsComplex_should_create_property_type
public void AsComplex_should_create_property_type()
{
var property = new EdmProperty().AsComplex(new EdmComplexType());
Assert.NotNull(property.PropertyType);
Assert.True(property.PropertyType.IsComplexType);
Assert.Equal(false, property.PropertyType.IsNullable);
}
示例7: GetStoreGeneratedPattern_should_return_null_when_not_set
public void GetStoreGeneratedPattern_should_return_null_when_not_set()
{
var property = new EdmProperty().AsPrimitive();
var storeGeneratedPattern = property.GetStoreGeneratedPattern();
Assert.Null(storeGeneratedPattern);
}
示例8: MapPrimitiveOrComplexOrEnumProperty
private EdmProperty MapPrimitiveOrComplexOrEnumProperty(
PropertyInfo propertyInfo, Func<StructuralTypeConfiguration> structuralTypeConfiguration,
bool discoverComplexTypes = false)
{
//Contract.Requires(propertyInfo != null);
var property = propertyInfo.AsEdmPrimitiveProperty();
if (property == null)
{
var propertyType = propertyInfo.PropertyType;
var complexType = _typeMapper.MapComplexType(propertyType, discoverComplexTypes);
if (complexType != null)
{
property = new EdmProperty
{
Name = propertyInfo.Name
}.AsComplex(complexType);
}
else
{
var isNullable = propertyType.TryUnwrapNullableType(out propertyType);
if (propertyType.IsEnum)
{
var enumType = _typeMapper.MapEnumType(propertyType);
if (enumType != null)
{
property = new EdmProperty
{
Name = propertyInfo.Name,
}.AsEnum(enumType);
property.PropertyType.IsNullable = isNullable;
}
}
}
}
if (property != null)
{
property.SetClrPropertyInfo(propertyInfo);
new AttributeMapper(_typeMapper.MappingContext.AttributeProvider)
.Map(propertyInfo, property.Annotations);
if (!property.PropertyType.IsComplexType)
{
_typeMapper.MappingContext.ConventionsConfiguration.ApplyPropertyConfiguration(
propertyInfo, () => structuralTypeConfiguration().Property(new PropertyPath(propertyInfo)));
}
}
return property;
}
示例9: Configure_should_update_model_dateTime_precision
public void Configure_should_update_model_dateTime_precision()
{
var configuration = CreateConfiguration();
configuration.Precision = 255;
var property = new EdmProperty().AsPrimitive();
configuration.Configure(property);
Assert.Equal((byte)255, property.PropertyType.PrimitiveTypeFacets.Precision);
}
示例10: Configure_should_update_IsUnicode
public void Configure_should_update_IsUnicode()
{
var configuration = CreateConfiguration();
configuration.IsUnicode = true;
var property = new EdmProperty().AsPrimitive();
configuration.Configure(property);
Assert.Equal(true, property.PropertyType.PrimitiveTypeFacets.IsUnicode);
}
示例11: SetStoreGeneratedPattern_should_create_annotation_and_add_to_property_facets
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);
}
示例12: Configure_should_update_model_decimal_scale_but_not_precision
public void Configure_should_update_model_decimal_scale_but_not_precision()
{
var configuration = CreateConfiguration();
configuration.Scale = 70;
var property = new EdmProperty().AsPrimitive();
configuration.Configure(property);
Assert.Equal((byte)70, property.PropertyType.PrimitiveTypeFacets.Scale);
Assert.Equal(null, property.PropertyType.PrimitiveTypeFacets.Precision);
}
示例13: Configure_should_update_MaxLength
public void Configure_should_update_MaxLength()
{
var property = new EdmProperty().AsPrimitive();
var configuration = CreateConfiguration();
configuration.MaxLength = 1;
configuration.Configure(property);
Assert.Equal(1, property.PropertyType.PrimitiveTypeFacets.MaxLength);
}
示例14: Configure_should_set_CSpace_configuration_annotation
public void Configure_should_set_CSpace_configuration_annotation()
{
var configuration = CreateConfiguration();
var property = new EdmProperty().AsPrimitive();
Assert.Null(property.GetConfiguration());
configuration.Configure(property);
Assert.Same(configuration, property.GetConfiguration());
}
示例15: SetStoreGeneratedPattern_should_update_existing_annotation
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);
}