本文整理汇总了C#中ClassMap类的典型用法代码示例。如果您正苦于以下问题:C# ClassMap类的具体用法?C# ClassMap怎么用?C# ClassMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassMap类属于命名空间,在下文中一共展示了ClassMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
}
开发者ID:nsreddy1986,项目名称:fluent-nhibernate,代码行数:25,代码来源:ManyToManyTableNameTests.cs
示例2: CanCreateClassMap
public void CanCreateClassMap()
{
var classMap = new ClassMap<Artist>();
ClassMapping mapping = classMap.GetClassMapping();
mapping.Type.ShouldEqual(typeof(Artist));
}
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:7,代码来源:ClassMapTester.cs
示例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();
}
开发者ID:Zaixu,项目名称:Lucene.Net.Linq,代码行数:7,代码来源:EnumerableContainsTests.cs
示例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");
}
开发者ID:heyitsanewb,项目名称:PokeWorld-Online,代码行数:25,代码来源:ManyToManyTableNameTests.cs
示例5: GenerateIdsFor
public void GenerateIdsFor(object entity, ClassMap classMap)
{
this.currentClassMap = classMap;
this.currentEntity = entity;
this.Visit(classMap);
}
开发者ID:andoco,项目名称:mongodb-csharp,代码行数:7,代码来源:IdGenerator.cs
示例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;
}
开发者ID:jjchoi,项目名称:fluent-nhibernate,代码行数:9,代码来源:KeyManyToOneConventionTests.cs
示例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));
}
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:10,代码来源:ClassMapTester.cs
示例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));
}
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:10,代码来源:ClassMapTester.cs
示例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));
}
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:10,代码来源:ClassMapTester.cs
示例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();
}
开发者ID:garrisonx,项目名称:NH3BegginnersGuide,代码行数:10,代码来源:DefaultLazyHelperTests.cs
示例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);
}
开发者ID:nsreddy1986,项目名称:fluent-nhibernate,代码行数:10,代码来源:AutoImportHelperTests.cs
示例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();
}
开发者ID:garrisonx,项目名称:NH3BegginnersGuide,代码行数:10,代码来源:DefaultLazyHelperTests.cs
示例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");
}
开发者ID:garrisonx,项目名称:NH3BegginnersGuide,代码行数:10,代码来源:DefaultAccessHelperTests.cs
示例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);
}
开发者ID:JamesKovacs,项目名称:fluent-nhibernate,代码行数:11,代码来源:ExternalComponentOutputSpecs.cs
示例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;
}
开发者ID:andoco,项目名称:mongodb-csharp,代码行数:11,代码来源:DeleteDocumentMapper.cs
示例16: 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);
}
开发者ID:nsreddy1986,项目名称:fluent-nhibernate,代码行数:11,代码来源:ComponentConventionTests.cs
示例17: establish_context
public override void establish_context()
{
var component_map = new ComponentMap<Component>();
component_map.Map(x => x.Property);
var class_map = new ClassMap<Target>();
class_map.Component(x => x.Component);
persistence_model = new PersistenceModel();
persistence_model.Add(class_map);
persistence_model.Add(component_map);
}
开发者ID:roend83,项目名称:fluent-nhibernate,代码行数:12,代码来源:ComponentMapSpecs.cs
示例18: MemberMap
public MemberMap(ClassMap classMap, MemberInfo memberInfo)
{
ClassMap = classMap;
MemberInfo = memberInfo;
Type = memberInfo is PropertyInfo
? (memberInfo as PropertyInfo).PropertyType
: ((FieldInfo) memberInfo).FieldType;
ColumnName = GetColumnName(memberInfo);
ValueSerializer = ValueSerializerProvider.GetSerializer(Type);
}
开发者ID:Jacky1,项目名称:cassandra-sharp,代码行数:12,代码来源:MemberMap.cs
示例19: CanMapTablePerClass
public void CanMapTablePerClass()
{
var classMap = new ClassMap<Employee>();
classMap.JoinedSubClass<SalaryEmployee>("SalaryEmployeeID", salaryMap => salaryMap.Map(x => x.Salary));
var classmapping = classMap.GetClassMapping();
var salaryMapping = classmapping.Subclasses.FirstOrDefault() as JoinedSubclassMapping;
salaryMapping.ShouldNotBeNull();
salaryMapping.Type.ShouldEqual(typeof (SalaryEmployee));
salaryMapping.Key.Column.ShouldEqual("SalaryEmployeeID");
salaryMapping.Properties.ShouldHaveCount(1);
}
开发者ID:paulbatum,项目名称:Fluent-NHibernate-Semantic-Model-Rewrite,代码行数:12,代码来源:ClassMapTester.cs
示例20: VerifyModel
private void VerifyModel(Action<HibernateMapping> modelVerification)
{
var classMap = new ClassMap<ExampleClass>();
model.Add(classMap);
var generatedModels = model.BuildMappings();
var modelInstance = generatedModels
.First(x => x.Classes.FirstOrDefault(c => c.Type == typeof(ExampleClass)) != null);
modelVerification(modelInstance);
}
开发者ID:sbakshi,项目名称:fluent-nhibernate,代码行数:12,代码来源:HibernateMappingConventionTests.cs
注:本文中的ClassMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论