本文整理汇总了C#中ClassMap.Id方法的典型用法代码示例。如果您正苦于以下问题:C# ClassMap.Id方法的具体用法?C# ClassMap.Id怎么用?C# ClassMap.Id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassMap
的用法示例。
在下文中一共展示了ClassMap.Id方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: NeverShouldSetDefaultLazyToFalse
public void NeverShouldSetDefaultLazyToFalse()
{
var classMap = new ClassMap<Target>();
classMap.Id(x => x.Id);
model.Add(classMap);
model.Conventions.Add(DefaultLazy.Never());
model.BuildMappings()
.First()
.DefaultLazy.ShouldBeFalse();
}
示例4: AlwaysShouldSetDefaultLazyToTrue
public void AlwaysShouldSetDefaultLazyToTrue()
{
var classMap = new ClassMap<Target>();
classMap.Id(x => x.Id);
model.Add(classMap);
model.Conventions.Add(DefaultLazy.Always());
model.BuildMappings()
.First()
.DefaultLazy.ShouldBeTrue();
}
示例5: ShouldSetDefaultAccessToValue
public void ShouldSetDefaultAccessToValue()
{
var classMap = new ClassMap<Target>();
classMap.Id(x => x.Id);
model.Add(classMap);
model.Conventions.Add(DefaultAccess.Field());
model.BuildMappings()
.First()
.DefaultAccess.ShouldEqual("field");
}
示例6: ShouldSetDefaultAccessToValue
public void ShouldSetDefaultAccessToValue()
{
var classMap = new ClassMap<Target>();
classMap.Id(x => x.Id);
model.Add(classMap);
model.Conventions.Add(AutoImport.Never());
model.BuildMappings()
.First()
.AutoImport.ShouldEqual(false);
}
示例7: Mapping
private void Mapping(Action<ComponentPart<ComponentTarget>> mappingDefinition)
{
var classMap = new ClassMap<PropertyTarget>();
classMap.Id(x => x.Id);
var map = classMap.Component(x => x.Component, mappingDefinition);
mappingDefinition(map);
mapping = classMap;
mappingType = typeof(PropertyTarget);
}
示例8: VerifyModel
private void VerifyModel(Action<HibernateMapping> modelVerification)
{
var classMap = new ClassMap<ExampleClass>();
classMap.Id(x => x.Id);
model.Add(classMap);
var generatedModels = model.BuildMappings();
var modelInstance = generatedModels
.First(x => x.Classes.FirstOrDefault(c => c.Type == typeof(ExampleClass)) != null);
modelVerification(modelInstance);
}
示例9: AlwaysShouldSetDefaultLazyToTrue
public void AlwaysShouldSetDefaultLazyToTrue()
{
var classMap = new ClassMap<Target>();
classMap.Id(x => x.Id);
model.Add(classMap);
model.Conventions.Add(DefaultLazy.Always());
model.Conventions.Add(DefaultCascade.All());
var mapping = model.BuildMappings().First();
mapping.DefaultLazy.ShouldBeTrue();
mapping.DefaultCascade.ShouldEqual("all");
}
示例10: ShouldntDuplicateJoinMapping
public void ShouldntDuplicateJoinMapping()
{
var model = new PersistenceModel();
var classMap = new ClassMap<Target>();
classMap.Id(x => x.Id);
classMap.Join("other", m => m.Map(x => x.Property));
model.Add(classMap);
model.Configure(cfg);
cfg.ClassMappings.First()
.JoinClosureIterator.Count().ShouldEqual(1);
}
示例11: ShouldSetForeignKeyOnJoin
public void ShouldSetForeignKeyOnJoin()
{
var classMap = new ClassMap<ExampleInheritedClass>();
classMap.Id(x => x.Id);
classMap.Join("two", m => { });
model.Add(classMap);
model.BuildMappings()
.First()
.Classes.First()
.Joins.First()
.Key.Columns.First().Name.ShouldEqual("ExampleInheritedClass!");
}
示例12: establish_context
public override void establish_context()
{
model = new PersistenceModel();
var comp_map = new ComponentMap<ComponentTarget>();
comp_map.Map(x => x.Property);
model.Add(comp_map);
var map = new ClassMap<Target>();
map.Id(x => x.Id);
map.Component(x => x.Component)
.ColumnPrefix(column_prefix);
model.Add(map);
}
示例13: ShouldSetForeignKeyOnManyToMany
public void ShouldSetForeignKeyOnManyToMany()
{
var classMap = new ClassMap<ExampleInheritedClass>();
classMap.Id(x => x.Id);
classMap.HasManyToMany(x => x.Children);
model.Add(classMap);
model.BuildMappings()
.First()
.Classes.First()
.Collections.First()
.Key.Columns.First().Name.ShouldEqual("ExampleInheritedClass!");
}
示例14: ShouldSetForeignKeyOnManyToOne
public void ShouldSetForeignKeyOnManyToOne()
{
var classMap = new ClassMap<ExampleClass>();
classMap.Id(x => x.Id);
classMap.References(x => x.Parent);
model.Add(classMap);
model.BuildMappings()
.First()
.Classes.First()
.References.First()
.Columns.First().Name.ShouldEqual("Parent!");
}
示例15: 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");
}