本文整理匯總了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