本文整理汇总了C#中PersistenceModel.BuildMappings方法的典型用法代码示例。如果您正苦于以下问题:C# PersistenceModel.BuildMappings方法的具体用法?C# PersistenceModel.BuildMappings怎么用?C# PersistenceModel.BuildMappings使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PersistenceModel
的用法示例。
在下文中一共展示了PersistenceModel.BuildMappings方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: render_xml
private string render_xml(Action<PersistenceModel> addMappings)
{
var model = new PersistenceModel();
addMappings(model);
var mappings = model.BuildMappings();
var doc = new MappingXmlSerializer().Serialize(mappings.First());
return doc.OuterXml;
}
示例4: ShouldAllowOverridingOfDefaultInConventions
public void ShouldAllowOverridingOfDefaultInConventions()
{
var model = new PersistenceModel();
var map = new ClassMap<IdentityExamples>();
map.Id(x => x.Int);
model.Conventions.Add(new IdConvention());
model.Add(map);
var @class = model.BuildMappings()
.First()
.Classes.First();
((IdMapping)@class.Id).Generator.Class.ShouldEqual("increment");
}
示例5: SetUp
public void SetUp()
{
PersistenceModel model = new PersistenceModel();
model.Conventions.Add(new BackfieldAccessConvention());
model.Add(new CompositeIdModelMapping());
model.Add(new ManyToManyModelMapping());
model.Add(new ManyToOneModelMapping());
model.Add(new OneToOneModelMapping());
model.Add(new ParentModelMapping());
var classMappings = model.BuildMappings().SelectMany(x => x.Classes).ToDictionary(x => x.Type);
compositeId = classMappings[typeof(CompositeIdModel)];
manyToMany = classMappings[typeof(ManyToManyModel)];
manyToOne = classMappings[typeof(ManyToOneModel)];
oneToOne = classMappings[typeof(OneToOneModel)];
parent = classMappings[typeof(ParentModel)];
}
示例6: ShouldAllowSettingOfKeyInConvention
public void ShouldAllowSettingOfKeyInConvention()
{
var model = new PersistenceModel();
var parent = new ClassMap<Parent>();
var child = new SubclassMap<Child>();
model.Add(parent);
model.Add(child);
model.Conventions.Add<SCKeyConvention>();
var subclass = model.BuildMappings()
.SelectMany(x => x.Classes)
.First()
.Subclasses.First();
((JoinedSubclassMapping)subclass).Key.Columns.First().Name.ShouldEqual("xxx");
((JoinedSubclassMapping)subclass).Key.Columns.Count().ShouldEqual(1);
}
示例7: ComponentWithPropertiesShouldAddToModelComponentsCollection
public void ComponentWithPropertiesShouldAddToModelComponentsCollection()
{
var classMap = new ClassMap<Parent>();
classMap.Id(x => x.Id);
var subclassMap = new SubclassMap<Child>();
subclassMap.Component(x => x.Component, c => c.Map(x => x.Name));
var model = new PersistenceModel();
model.Add(classMap);
model.Add(subclassMap);
model.BuildMappings()
.First()
.Classes.First()
.Subclasses.First()
.Components.Count().ShouldEqual(1);
}
开发者ID:sbakshi,项目名称:fluent-nhibernate,代码行数:21,代码来源:SubclassMapForSubclassSubPartModelGenerationTests.cs
示例8: Where
private string Where(string where)
{
var classMap = new ClassMap<Target>();
classMap.Id(x => x.Id);
classMap.HasMany(x => x.Children)
.Where(where);
var model = new PersistenceModel();
model.Add(classMap);
return model.BuildMappings()
.First()
.Classes.First()
.Collections.First()
.Where;
}
示例9: 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");
}
示例10: 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");
}