本文整理汇总了C#中System.Data.Entity.Core.Metadata.Edm.DbDatabaseMapping.AddAssociationSetMapping方法的典型用法代码示例。如果您正苦于以下问题:C# DbDatabaseMapping.AddAssociationSetMapping方法的具体用法?C# DbDatabaseMapping.AddAssociationSetMapping怎么用?C# DbDatabaseMapping.AddAssociationSetMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.Entity.Core.Metadata.Edm.DbDatabaseMapping
的用法示例。
在下文中一共展示了DbDatabaseMapping.AddAssociationSetMapping方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 EdmModel().Initialize());
var foreignKeyConstraint
= new ForeignKeyBuilder(databaseMapping.Database, "FK")
{
PrincipalTable
= new EntityType("P", XmlConstants.TargetNamespace_3, DataSpace.SSpace)
};
Assert.Equal(OperationAction.None, foreignKeyConstraint.DeleteAction);
var table = databaseMapping.Database.AddTable("T");
table.AddForeignKey(foreignKeyConstraint);
var associationType
= new AssociationType
{
SourceEnd = new AssociationEndMember("S", new EntityType()),
TargetEnd = new AssociationEndMember("T", new EntityType())
};
associationType.SourceEnd.RelationshipMultiplicity = RelationshipMultiplicity.Many;
associationType.TargetEnd.RelationshipMultiplicity = RelationshipMultiplicity.Many;
var associationSetMapping = databaseMapping.AddAssociationSetMapping(
new AssociationSet("AS", associationType), new EntitySet());
associationSetMapping.StoreEntitySet = databaseMapping.Database.GetEntitySet(table);
((IDbMappingConvention)new ManyToManyCascadeDeleteConvention()).Apply(databaseMapping);
Assert.Equal(OperationAction.Cascade, foreignKeyConstraint.DeleteAction);
}
示例2: GenerateAssociationSetMapping
private static AssociationSetMapping GenerateAssociationSetMapping(
AssociationType associationType,
DbDatabaseMapping databaseMapping,
AssociationEndMember principalEnd,
AssociationEndMember dependentEnd,
EntityType dependentTable)
{
DebugCheck.NotNull(associationType);
DebugCheck.NotNull(databaseMapping);
DebugCheck.NotNull(principalEnd);
DebugCheck.NotNull(dependentEnd);
DebugCheck.NotNull(dependentTable);
var associationSetMapping
= databaseMapping.AddAssociationSetMapping(
databaseMapping.Model.GetAssociationSet(associationType),
databaseMapping.Database.GetEntitySet(dependentTable));
associationSetMapping.StoreEntitySet = databaseMapping.Database.GetEntitySet(dependentTable);
associationSetMapping.SourceEndMapping.AssociationEnd = principalEnd;
associationSetMapping.TargetEndMapping.AssociationEnd = dependentEnd;
return associationSetMapping;
}
示例3: Configure_should_configure_function_mapping
public void Configure_should_configure_function_mapping()
{
var functionsConfiguration = new ModificationFunctionsConfiguration();
var functionConfiguration = new ModificationFunctionConfiguration();
functionConfiguration.HasName("Func");
functionsConfiguration.Insert(functionConfiguration);
var mockPropertyInfo = new MockPropertyInfo();
var navigationPropertyConfiguration
= new NavigationPropertyConfiguration(mockPropertyInfo)
{
ModificationFunctionsConfiguration = functionsConfiguration
};
var databaseMapping
= new DbDatabaseMapping()
.Initialize(new EdmModel(DataSpace.CSpace), new EdmModel(DataSpace.SSpace));
var associationSetMapping = databaseMapping.AddAssociationSetMapping(
new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)), new EntitySet());
var dependentTable = databaseMapping.Database.AddTable("T");
associationSetMapping.StoreEntitySet = databaseMapping.Database.GetEntitySet(dependentTable);
associationSetMapping.AssociationSet.ElementType.SetConfiguration(navigationPropertyConfiguration);
associationSetMapping.SourceEndMapping.EndMember = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
associationSetMapping.SourceEndMapping.EndMember.SetClrPropertyInfo(mockPropertyInfo);
navigationPropertyConfiguration.Configure(associationSetMapping, databaseMapping, ProviderRegistry.Sql2008_ProviderManifest);
Assert.Equal("Func", associationSetMapping.ModificationFunctionMapping.InsertFunctionMapping.Function.Name);
}
示例4: Configure_should_configure_mapping
public void Configure_should_configure_mapping()
{
var manyToManyAssociationMappingConfiguration = new ManyToManyAssociationMappingConfiguration();
manyToManyAssociationMappingConfiguration.ToTable("Foo");
var mockPropertyInfo = new MockPropertyInfo(typeof(AType1), "N");
var navigationPropertyConfiguration
= new NavigationPropertyConfiguration(mockPropertyInfo)
{
AssociationMappingConfiguration = manyToManyAssociationMappingConfiguration
};
var databaseMapping
= new DbDatabaseMapping()
.Initialize(new EdmModel(DataSpace.CSpace), new EdmModel(DataSpace.SSpace));
var associationSetMapping = databaseMapping.AddAssociationSetMapping(
new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)), new EntitySet());
var dependentTable = databaseMapping.Database.AddTable("T");
associationSetMapping.StoreEntitySet = databaseMapping.Database.GetEntitySet(dependentTable);
associationSetMapping.AssociationSet.ElementType.SetConfiguration(navigationPropertyConfiguration);
associationSetMapping.SourceEndMapping.AssociationEnd = new AssociationEndMember("S", new EntityType("E", "N", DataSpace.CSpace));
associationSetMapping.SourceEndMapping.AssociationEnd.SetClrPropertyInfo(mockPropertyInfo);
navigationPropertyConfiguration.Configure(associationSetMapping, databaseMapping, ProviderRegistry.Sql2008_ProviderManifest);
Assert.Equal("Foo", associationSetMapping.Table.GetTableName().Name);
}
示例5: Configure_should_configure_mapping
public void Configure_should_configure_mapping()
{
var manyToManyAssociationMappingConfiguration = new ManyToManyAssociationMappingConfiguration();
manyToManyAssociationMappingConfiguration.ToTable("Foo");
var mockPropertyInfo = new MockPropertyInfo();
var navigationPropertyConfiguration
= new NavigationPropertyConfiguration(mockPropertyInfo)
{
AssociationMappingConfiguration = manyToManyAssociationMappingConfiguration
};
var databaseMapping
= new DbDatabaseMapping()
.Initialize(new EdmModel().Initialize(), new EdmModel().Initialize());
var associationSetMapping = databaseMapping.AddAssociationSetMapping(
new AssociationSet("AS", new AssociationType()), new EntitySet());
var dependentTable = databaseMapping.Database.AddTable("T");
associationSetMapping.StoreEntitySet = databaseMapping.Database.GetEntitySet(dependentTable);
associationSetMapping.AssociationSet.ElementType.SetConfiguration(navigationPropertyConfiguration);
associationSetMapping.SourceEndMapping.EndMember = new AssociationEndMember("S", new EntityType());
associationSetMapping.SourceEndMapping.EndMember.SetClrPropertyInfo(mockPropertyInfo);
navigationPropertyConfiguration.Configure(associationSetMapping, databaseMapping);
Assert.Equal("Foo", associationSetMapping.Table.GetTableName().Name);
}