本文整理汇总了C#中ClassMap类的典型用法代码示例。如果您正苦于以下问题:C# ClassMap类的具体用法?C# ClassMap怎么用?C# ClassMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClassMap类属于命名空间,在下文中一共展示了ClassMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
示例2: CanCreateClassMap
public void CanCreateClassMap()
{
var classMap = new ClassMap<Artist>();
ClassMapping mapping = classMap.GetClassMapping();
mapping.Type.ShouldEqual(typeof(Artist));
}
示例3: SetUp
public void SetUp()
{
tourMap = new ClassMap<Tour>(Version.LUCENE_30);
tourMap.Property(p => p.AccommodationAges).Stored().NotAnalyzed();
tourMap.Property(p => p.TotalPriceMin).Stored().NotAnalyzed();
tourMap.Property(p => p.TotalPriceMax).Stored().NotAnalyzed();
}
示例4: 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");
}
示例5: GenerateIdsFor
public void GenerateIdsFor(object entity, ClassMap classMap)
{
this.currentClassMap = classMap;
this.currentEntity = entity;
this.Visit(classMap);
}
示例6: Mapping
private void Mapping(Action<KeyManyToOnePart> mappingDefinition)
{
var classMap = new ClassMap<ExampleClass>();
var map = classMap.CompositeId()
.KeyProperty(x => x.Id)
.KeyReference(x => x.Parent, mappingDefinition);
mapping = classMap;
}
示例7: CanMapProperty
public void CanMapProperty()
{
var classMap = new ClassMap<Artist>();
classMap.Map(x => x.Name);
ClassMapping mapping = classMap.GetClassMapping();
var property = mapping.Properties.FirstOrDefault();
property.ShouldNotBeNull();
property.MappedMember.ShouldEqual(ReflectionHelper.GetMember<Artist>(x => x.Name));
}
示例8: CanMapCollection
public void CanMapCollection()
{
var classMap = new ClassMap<Artist>();
classMap.HasMany<Album>(x => x.Albums);
ClassMapping mapping = classMap.GetClassMapping();
var collection = mapping.Collections.FirstOrDefault() as BagMapping;
collection.ShouldNotBeNull();
collection.MappedMember.ShouldEqual(ReflectionHelper.GetMember<Artist>(x => x.Albums));
}
示例9: CanMapReference
public void CanMapReference()
{
var classMap = new ClassMap<Album>();
classMap.References(x => x.Artist);
ClassMapping mapping = classMap.GetClassMapping();
var reference = mapping.References.FirstOrDefault();
reference.ShouldNotBeNull();
reference.MappedMember.ShouldEqual(ReflectionHelper.GetMember<Album>(x => x.Artist));
}
示例10: 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();
}
示例11: 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);
}
示例12: 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();
}
示例13: 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");
}
示例14: establish_context
public override void establish_context()
{
inline_component = new ClassMap<Target>();
inline_component.Component(x => x.ComponentProperty, c => c.Map(x => x.Property));
external_component = new ComponentMap<Component>();
external_component.Map(x => x.Property);
reference_component = new ClassMap<Target>();
reference_component.Component(x => x.ComponentProperty);
}
示例15: CreateDocument
public Document CreateDocument(ClassMap classMap, object entity)
{
if (entity == null)
throw new ArgumentNullException("entity");
this.entity = entity;
this.document = new Document();
classMap.Accept(this);
return this.document;
}