本文整理汇总了C#中ClassMap.HasManyToMany方法的典型用法代码示例。如果您正苦于以下问题:C# ClassMap.HasManyToMany方法的具体用法?C# ClassMap.HasManyToMany怎么用?C# ClassMap.HasManyToMany使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassMap
的用法示例。
在下文中一共展示了ClassMap.HasManyToMany方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldAllowConventionsToAlterBiDirectionalTableNames
public void ShouldAllowConventionsToAlterBiDirectionalTableNames()
{
var model = new PersistenceModel();
var leftMap = new ClassMap<Left>();
leftMap.Id(x => x.Id);
leftMap.HasManyToMany(x => x.Rights);
var rightMap = new ClassMap<Right>();
rightMap.Id(x => x.Id);
rightMap.HasManyToMany(x => x.Lefts);
model.Add(leftMap);
model.Add(rightMap);
model.Conventions.Add<TestTableNameConvention>();
var mappings = model.BuildMappings();
var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
var rightMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Right)).First();
leftMapping.Collections.First().TableName.ShouldEqual("Lefts_Rights");
rightMapping.Collections.First().TableName.ShouldEqual("Lefts_Rights");
}
示例2: ShouldHaveSameTableNameForBothSidesOfMappingWhenRightSpecified
public void ShouldHaveSameTableNameForBothSidesOfMappingWhenRightSpecified()
{
var model = new PersistenceModel();
var leftMap = new ClassMap<Left>();
leftMap.Id(x => x.Id);
leftMap.HasManyToMany(x => x.Rights);
var rightMap = new ClassMap<Right>();
rightMap.Id(x => x.Id);
rightMap.HasManyToMany(x => x.Lefts)
.Table("MyJoinTable");
model.Add(leftMap);
model.Add(rightMap);
var mappings = model.BuildMappings();
var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
var rightMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Right)).First();
leftMapping.Collections.First().TableName.ShouldEqual("MyJoinTable");
rightMapping.Collections.First().TableName.ShouldEqual("MyJoinTable");
}
示例3: ShouldSetForeignKeyOnManyToMany
public void ShouldSetForeignKeyOnManyToMany()
{
var classMap = new ClassMap<ExampleInheritedClass>();
classMap.HasManyToMany(x => x.Children);
model.Add(classMap);
model.BuildMappings()
.First()
.Classes.First()
.Collections.First()
.Key.Columns.First().Name.ShouldEqual("ExampleInheritedClass!");
}
示例4: VerifyModel
private void VerifyModel(Action<ICollectionMapping> modelVerification)
{
var classMap = new ClassMap<ExampleInheritedClass>();
classMap.Id(x => x.Id);
var map = classMap.HasManyToMany(x => x.Children);
model.Add(classMap);
var generatedModels = model.BuildMappings();
var modelInstance = generatedModels
.First(x => x.Classes.FirstOrDefault(c => c.Type == typeof(ExampleInheritedClass)) != null)
.Classes.First()
.Collections.First();
modelVerification(modelInstance);
}
示例5: ShouldHaveSameTableNameForBothSidesOfMappingWhenHasMultipleBiDirectionalManyToManysOnSameEntities
public void ShouldHaveSameTableNameForBothSidesOfMappingWhenHasMultipleBiDirectionalManyToManysOnSameEntities()
{
var model = new PersistenceModel();
var leftMap = new ClassMap<Left>();
leftMap.Id(x => x.Id);
leftMap.HasManyToMany(x => x.Rights);
leftMap.HasManyToMany(x => x.SecondRights);
var rightMap = new ClassMap<Right>();
rightMap.Id(x => x.Id);
rightMap.HasManyToMany(x => x.Lefts);
rightMap.HasManyToMany(x => x.SecondLefts);
model.Add(leftMap);
model.Add(rightMap);
var mappings = model.BuildMappings();
var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
var rightMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Right)).First();
leftMapping.Collections.First().TableName.ShouldEqual("LeftsToRights");
rightMapping.Collections.First().TableName.ShouldEqual("LeftsToRights");
leftMapping.Collections.ElementAt(1).TableName.ShouldEqual("SecondLeftsToSecondRights");
rightMapping.Collections.ElementAt(1).TableName.ShouldEqual("SecondLeftsToSecondRights");
}
示例6: ShouldHaveSameTableNameForUniDirectionalMapping
public void ShouldHaveSameTableNameForUniDirectionalMapping()
{
var model = new PersistenceModel();
var leftMap = new ClassMap<Left>();
leftMap.Id(x => x.Id);
leftMap.HasManyToMany(x => x.Rights);
var rightMap = new ClassMap<Right>();
rightMap.Id(x => x.Id);
model.Add(leftMap);
model.Add(rightMap);
var mappings = model.BuildMappings();
var leftMapping = mappings.SelectMany(x => x.Classes).Where(x => x.Type == typeof(Left)).First();
leftMapping.Collections.First().TableName.ShouldEqual("RightToLeft");
}
示例7: ShouldApplyToHasManyToMany
public void ShouldApplyToHasManyToMany()
{
var conventions = new[]
{
MockRepository.GenerateMock<IMappingPartConvention>()
};
var cm = new ClassMap<ManyToManyTarget>();
var manyToMany = cm.HasManyToMany(x => x.BagOfChildren);
conventionFinder.Stub(x => x.Find<IMappingPartConvention>())
.Return(conventions);
conventions[0].Stub(x => x.Accept(null))
.IgnoreArguments()
.Return(true);
convention.Apply(cm);
conventions[0].AssertWasCalled(x => x.Apply(manyToMany));
}
开发者ID:HudsonAkridge,项目名称:fluent-nhibernate,代码行数:20,代码来源:ClassMappingPartDiscoveryConventionTester.cs