本文整理汇总了C#中ClassMap.HasMany方法的典型用法代码示例。如果您正苦于以下问题:C# ClassMap.HasMany方法的具体用法?C# ClassMap.HasMany怎么用?C# ClassMap.HasMany使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassMap
的用法示例。
在下文中一共展示了ClassMap.HasMany方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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));
}
示例2: ShouldSetForeignKeyOnOneToMany
public void ShouldSetForeignKeyOnOneToMany()
{
var classMap = new ClassMap<ExampleInheritedClass>();
classMap.Id(x => x.Id);
classMap.HasMany(x => x.Children);
model.Add(classMap);
model.BuildMappings()
.First()
.Classes.First()
.Collections.First()
.Key.Columns.First().Name.ShouldEqual("ExampleInheritedClass!");
}
示例3: VerifyModel
private void VerifyModel(Action<ICollectionMapping> modelVerification)
{
var classMap = new ClassMap<ExampleInheritedClass>();
var map = classMap.HasMany(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);
}
示例4: 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;
}
示例5: Mapping
private void Mapping(Action<OneToManyPart<ExampleClass>> mappingDefinition)
{
var classMap = new ClassMap<ExampleParentClass>();
classMap.Id(x => x.Id);
var map = classMap.HasMany(x => x.Examples)
.AsArray(x => x.Id);
mappingDefinition(map);
mapping = classMap;
mappingType = typeof(ExampleParentClass);
}
示例6: VerifyModel
private void VerifyModel(Action<ArrayMapping> modelVerification)
{
var classMap = new ClassMap<ExampleParentClass>();
classMap.Id(x => x.Id);
var map = classMap.HasMany(x => x.Examples)
.AsArray(x => x.Id);
model.Add(classMap);
var generatedModels = model.BuildMappings();
var modelInstance = generatedModels
.First(x => x.Classes.FirstOrDefault(c => c.Type == typeof(ExampleParentClass)) != null)
.Classes.First()
.Collections.First();
modelVerification((ArrayMapping)modelInstance);
}
示例7: ShouldApplyToHasMany
public void ShouldApplyToHasMany()
{
var conventions = new[]
{
MockRepository.GenerateMock<IMappingPartConvention>()
};
var cm = new ClassMap<OneToManyTarget>();
var oneToMany = cm.HasMany(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(oneToMany));
}
开发者ID:HudsonAkridge,项目名称:fluent-nhibernate,代码行数:20,代码来源:ClassMappingPartDiscoveryConventionTester.cs