本文整理汇总了C#中System.Data.Entity.Edm.EdmAssociationType类的典型用法代码示例。如果您正苦于以下问题:C# EdmAssociationType类的具体用法?C# EdmAssociationType怎么用?C# EdmAssociationType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EdmAssociationType类属于System.Data.Entity.Edm命名空间,在下文中一共展示了EdmAssociationType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Initialize_should_create_association_ends
public void Initialize_should_create_association_ends()
{
var associationType = new EdmAssociationType().Initialize();
Assert.NotNull(associationType.SourceEnd);
Assert.NotNull(associationType.TargetEnd);
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:EdmAssociationTypeExtensionsTests.cs
示例2: 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
示例3: GetOtherEnd_should_return_correct_end
public void GetOtherEnd_should_return_correct_end()
{
var associationType = new EdmAssociationType().Initialize();
Assert.Same(associationType.SourceEnd, associationType.GetOtherEnd(associationType.TargetEnd));
Assert.Same(associationType.TargetEnd, associationType.GetOtherEnd(associationType.SourceEnd));
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:EdmAssociationTypeExtensionsTests.cs
示例4: Can_get_and_set_configuration_facet
public void Can_get_and_set_configuration_facet()
{
var associationType = new EdmAssociationType().Initialize();
associationType.SetConfiguration(42);
Assert.Equal(42, associationType.GetConfiguration());
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:EdmAssociationTypeExtensionsTests.cs
示例5: Configure_should_configure_inverse
public void Configure_should_configure_inverse()
{
var inverseMockPropertyInfo = new MockPropertyInfo();
var navigationPropertyConfiguration = new NavigationPropertyConfiguration(new MockPropertyInfo())
{
InverseNavigationProperty = inverseMockPropertyInfo
};
var associationType = new EdmAssociationType().Initialize();
var inverseAssociationType = new EdmAssociationType().Initialize();
var model = new EdmModel().Initialize();
model.AddAssociationType(inverseAssociationType);
var inverseNavigationProperty
= model.AddEntityType("T")
.AddNavigationProperty("N", inverseAssociationType);
inverseNavigationProperty.SetClrPropertyInfo(inverseMockPropertyInfo);
navigationPropertyConfiguration.Configure(
new EdmNavigationProperty
{
Association = associationType
}, model, new EntityTypeConfiguration(typeof(object)));
Assert.Same(associationType, inverseNavigationProperty.Association);
Assert.Same(associationType.SourceEnd, inverseNavigationProperty.ResultEnd);
Assert.Equal(0, model.GetAssociationTypes().Count());
}
开发者ID:junxy,项目名称:entityframework,代码行数:26,代码来源:NavigationPropertyConfigurationTests.cs
示例6: Apply_should_introduce_cascade_delete_on_constraints
public void Apply_should_introduce_cascade_delete_on_constraints()
{
var databaseMapping
= new DbDatabaseMapping()
.Initialize(new EdmModel().Initialize(), new DbDatabaseMetadata().Initialize());
var foreignKeyConstraint = new DbForeignKeyConstraintMetadata();
Assert.Equal(DbOperationAction.None, foreignKeyConstraint.DeleteAction);
var table = new DbTableMetadata();
table.ForeignKeyConstraints.Add(foreignKeyConstraint);
var associationType = new EdmAssociationType().Initialize();
associationType.SourceEnd.EndKind = EdmAssociationEndKind.Many;
associationType.SourceEnd.EntityType = new EdmEntityType();
associationType.TargetEnd.EndKind = EdmAssociationEndKind.Many;
associationType.TargetEnd.EntityType = new EdmEntityType();
var associationSetMapping = databaseMapping.AddAssociationSetMapping(new EdmAssociationSet { ElementType = associationType });
associationSetMapping.Table = table;
((IDbMappingConvention)new ManyToManyCascadeDeleteConvention()).Apply(databaseMapping);
Assert.Equal(DbOperationAction.Cascade, foreignKeyConstraint.DeleteAction);
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:26,代码来源:ManyToManyCascadeDeleteConventionTests.cs
示例7: IsManyToRequired_should_be_true_when_source_many_and_target_required
public void IsManyToRequired_should_be_true_when_source_many_and_target_required()
{
var associationType = new EdmAssociationType().Initialize();
associationType.SourceEnd.EndKind = EdmAssociationEndKind.Many;
associationType.TargetEnd.EndKind = EdmAssociationEndKind.Required;
Assert.True(associationType.IsManyToRequired());
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:8,代码来源:EdmAssociationTypeExtensionsTests.cs
示例8: Configure
internal override void Configure(
EdmAssociationType associationType, EdmAssociationEnd dependentEnd,
EntityTypeConfiguration entityTypeConfiguration)
{
//Contract.Requires(associationType != null);
//Contract.Requires(dependentEnd != null);
//Contract.Requires(entityTypeConfiguration != null);
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:8,代码来源:ConstraintConfiguration.cs
示例9: SetAssociationType
public static void SetAssociationType(
this DbForeignKeyConstraintMetadata fk, EdmAssociationType associationType)
{
Contract.Requires(fk != null);
Contract.Requires(associationType != null);
fk.Annotations.SetAnnotation(AssociationType, associationType);
}
开发者ID:junxy,项目名称:entityframework,代码行数:8,代码来源:DbForeignKeyConstraintMetadataExtensions.cs
示例10: Configure_should_throw_when_dependent_property_not_found
public void Configure_should_throw_when_dependent_property_not_found()
{
var constraintConfiguration = new ForeignKeyConstraintConfiguration(new[] { new MockPropertyInfo(typeof(int), "P").Object });
var associationType = new EdmAssociationType();
Assert.Equal(Strings.ForeignKeyPropertyNotFound("P", "T"), Assert.Throws<InvalidOperationException>(() => constraintConfiguration.Configure(associationType,
new EdmAssociationEnd { EntityType = new EdmEntityType { Name = "T" } }, new EntityTypeConfiguration(typeof(object)))).Message);
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:8,代码来源:ForeignKeyConstraintConfigurationTests.cs
示例11: Can_mark_association_as_independent
public void Can_mark_association_as_independent()
{
var associationType = new EdmAssociationType();
Assert.False(associationType.IsIndependent());
associationType.MarkIndependent();
Assert.True(associationType.IsIndependent());
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:10,代码来源:EdmAssociationTypeExtensionsTests.cs
示例12: Apply_should_not_discover_when_independent_constraint
public void Apply_should_not_discover_when_independent_constraint()
{
var associationType = new EdmAssociationType().Initialize();
associationType.MarkIndependent();
((IEdmConvention<EdmAssociationType>)new TypeNameForeignKeyDiscoveryConvention())
.Apply(associationType, new EdmModel().Initialize());
Assert.Null(associationType.Constraint);
}
开发者ID:junxy,项目名称:entityframework,代码行数:10,代码来源:ForeignKeyDiscoveryConventionBaseTests.cs
示例13: AddNavigationProperty_should_create_and_add_navigation_property
public void AddNavigationProperty_should_create_and_add_navigation_property()
{
var entityType = new EdmEntityType();
var associationType = new EdmAssociationType();
var navigationProperty = entityType.AddNavigationProperty("N", associationType);
Assert.NotNull(navigationProperty);
Assert.Equal("N", navigationProperty.Name);
Assert.Same(associationType, navigationProperty.Association);
Assert.True(entityType.NavigationProperties.Contains(navigationProperty));
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:12,代码来源:EdmEntityTypeExtensionsTests.cs
示例14: Apply_should_not_discover_when_no_clear_principal
public void Apply_should_not_discover_when_no_clear_principal()
{
var associationType = new EdmAssociationType().Initialize();
associationType.SourceEnd.EndKind
= associationType.TargetEnd.EndKind
= EdmAssociationEndKind.Many;
((IEdmConvention<EdmAssociationType>)new TypeNameForeignKeyDiscoveryConvention())
.Apply(associationType, new EdmModel().Initialize());
Assert.Null(associationType.Constraint);
}
开发者ID:junxy,项目名称:entityframework,代码行数:12,代码来源:ForeignKeyDiscoveryConventionBaseTests.cs
示例15: FixNavigationProperties
private static void FixNavigationProperties(
EdmModel model, EdmAssociationType unifiedAssociation, EdmAssociationType redundantAssociation)
{
foreach (var navigationProperty
in model.GetEntityTypes()
.SelectMany(e => e.NavigationProperties)
.Where(np => np.Association == redundantAssociation))
{
navigationProperty.Association = unifiedAssociation;
navigationProperty.ResultEnd = unifiedAssociation.SourceEnd;
}
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:12,代码来源:AssociationInverseDiscoveryConvention.cs
示例16: Apply_should_not_discover_when_existing_constraint
public void Apply_should_not_discover_when_existing_constraint()
{
var associationType = new EdmAssociationType().Initialize();
var associationConstraint = new EdmAssociationConstraint();
associationType.Constraint = associationConstraint;
((IEdmConvention<EdmAssociationType>)new TypeNameForeignKeyDiscoveryConvention())
.Apply(associationType, new EdmModel().Initialize());
Assert.Same(associationConstraint, associationType.Constraint);
}
开发者ID:junxy,项目名称:entityframework,代码行数:12,代码来源:ForeignKeyDiscoveryConventionBaseTests.cs
示例17: Apply_should_not_add_action_when_self_reference
public void Apply_should_not_add_action_when_self_reference()
{
var associationType = new EdmAssociationType().Initialize();
associationType.SourceEnd.EntityType
= associationType.TargetEnd.EntityType
= new EdmEntityType();
((IEdmConvention<EdmAssociationType>)new OneToManyCascadeDeleteConvention())
.Apply(associationType, new EdmModel().Initialize());
Assert.Equal(null, associationType.SourceEnd.DeleteAction);
Assert.Equal(null, associationType.TargetEnd.DeleteAction);
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:13,代码来源:OneToManyCascadeDeleteConventionTests.cs
示例18: Apply_should_not_add_action_when_has_existing_action
public void Apply_should_not_add_action_when_has_existing_action()
{
var associationType = new EdmAssociationType().Initialize();
associationType.SourceEnd.EntityType = new EdmEntityType();
associationType.TargetEnd.EntityType = new EdmEntityType();
associationType.SourceEnd.DeleteAction = EdmOperationAction.Restrict;
((IEdmConvention<EdmAssociationType>)new OneToManyCascadeDeleteConvention())
.Apply(associationType, new EdmModel().Initialize());
Assert.Equal(EdmOperationAction.Restrict, associationType.SourceEnd.DeleteAction);
Assert.Equal(null, associationType.TargetEnd.DeleteAction);
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:13,代码来源:OneToManyCascadeDeleteConventionTests.cs
示例19: Apply_is_noop_when_unknown_dependent
public void Apply_is_noop_when_unknown_dependent()
{
var model = new EdmModel().Initialize();
var associationType = new EdmAssociationType().Initialize();
var navigationProperty = new EdmNavigationProperty { Association = associationType };
var foreignKeyAnnotation = new ForeignKeyAttribute("AId");
navigationProperty.Annotations.SetClrAttributes(new[] { foreignKeyAnnotation });
((IEdmConvention<EdmNavigationProperty>)new ForeignKeyNavigationPropertyAttributeConvention())
.Apply(navigationProperty, model);
Assert.Null(associationType.Constraint);
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:13,代码来源:ForeignKeyAnnotationConventionTests.cs
示例20: HasCascadeDeletePath_should_return_true_for_self_ref_cascade
public void HasCascadeDeletePath_should_return_true_for_self_ref_cascade()
{
var model = new EdmModel().Initialize();
var entityType = model.AddEntityType("A");
var associationType = new EdmAssociationType().Initialize();
associationType.SourceEnd.EntityType
= associationType.TargetEnd.EntityType
= entityType;
associationType.SourceEnd.DeleteAction = EdmOperationAction.Cascade;
model.AddAssociationType(associationType);
Assert.True(model.HasCascadeDeletePath(entityType, entityType));
}
开发者ID:junxy,项目名称:entityframework,代码行数:13,代码来源:EdmModelExtensionsTests.cs
注:本文中的System.Data.Entity.Edm.EdmAssociationType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论