本文整理汇总了C#中ObjectRelationalMapper.ManyToOne方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectRelationalMapper.ManyToOne方法的具体用法?C# ObjectRelationalMapper.ManyToOne怎么用?C# ObjectRelationalMapper.ManyToOne使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectRelationalMapper
的用法示例。
在下文中一共展示了ObjectRelationalMapper.ManyToOne方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateMapping
public HbmMapping CreateMapping()
{
var orm = new ObjectRelationalMapper();
//主键生成策略(自增)
orm.Patterns.PoidStrategies.Add(new NativePoidPattern());
var entities = new[]
{
typeof(User),
typeof(PlusMaterial),
typeof(StockIn),
typeof(StockInDetail),
typeof(StockOut),
typeof(StockOutDetail),
};
orm.TablePerClass(entities);
//关系映射
orm.ManyToOne<StockInDetail, StockIn>();
orm.ManyToOne<StockOutDetail, StockOut>();
//数据库命名规则
var mapper = new Mapper(orm, new CoolPatternsAppliersHolder(orm));
orm.TablePerClass(entities);
var hc = mapper.CompileMappingFor(Assembly.Load("PMMS.Entities").GetTypes());
return hc;
}
示例2: WhenExplicitRegisteredRecognizeRelation
public void WhenExplicitRegisteredRecognizeRelation()
{
var mapper = new ObjectRelationalMapper();
mapper.TablePerClass<AEntity>();
mapper.TablePerClass<BEntity>();
mapper.ManyToOne<AEntity, BEntity>();
mapper.IsManyToOne(typeof (AEntity), typeof (BEntity)).Should().Be.True();
}
示例3: WhenFindInterfaceForRootClassThenRecognizeRelation
public void WhenFindInterfaceForRootClassThenRecognizeRelation()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Contact>();
orm.TablePerClass<UserGroup>();
orm.ManyToOne<UserGroup, ISecurity>();
orm.IsManyToOne(typeof (UserGroup), typeof (ISecurity)).Should().Be.True();
}
示例4: IntegrationWithObjectRelationalMapper
public void IntegrationWithObjectRelationalMapper()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Person>();
orm.TablePerClass<Animal>();
orm.ManyToOne<Person, Animal>();
HbmMapping mapping = GetMapping(orm);
VerifyMapping(mapping);
}
示例5: IntegrationWithObjectRelationalMapper
public void IntegrationWithObjectRelationalMapper()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Parent>();
orm.TablePerClass<Child>();
orm.ManyToOne<Child, Parent>();
HbmMapping mapping = GetMapping(orm);
VerifyMapping(mapping);
}
示例6: IntegrationWithObjectRelationalMapper
public void IntegrationWithObjectRelationalMapper()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<AEntity>();
orm.TablePerClass<BEntity>();
orm.ManyToOne<AEntity, BEntity>();
HbmMapping mapping = GetMapping(orm);
VerifyAEntityMapping(mapping);
}
示例7: IntegrationWithObjectRelationalMapper
public void IntegrationWithObjectRelationalMapper()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<AEntity>();
orm.TablePerClass<BEntity>();
orm.ManyToOne<AEntity, BEntity>();
orm.Cascade<AEntity, BEntity>(Cascade.Persist | Cascade.Remove);
HbmMapping mapping = GetMapping(orm);
VerifyMappingWithCascade(mapping);
}
示例8: WhenOrmCascadeIsAllThenApplyOndeleteCascade
public void WhenOrmCascadeIsAllThenApplyOndeleteCascade()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Parent>();
orm.TablePerClass<Child>();
orm.ManyToOne<Child, Parent>();
orm.Cascade<Parent, Child>(Cascade.All);
HbmMapping mapping = GetMapping(orm);
HbmClass rc = mapping.RootClasses.First(r => r.Name.Contains("Parent"));
var relation = rc.Properties.First(p => p.Name == "Children");
var collection = (HbmBag)relation;
collection.Key.ondelete.Should().Be(HbmOndelete.Cascade);
}
示例9: WhenOrmCascadeDoesNotIncludeDeleteNorDeleteOrhphanThenNotApplyOndeleteCascade
public void WhenOrmCascadeDoesNotIncludeDeleteNorDeleteOrhphanThenNotApplyOndeleteCascade()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Parent>();
orm.TablePerClass<Child>();
orm.ManyToOne<Child, Parent>();
orm.Cascade<Parent, Child>(Cascade.Persist | Cascade.ReAttach);
HbmMapping mapping = GetMapping(orm);
HbmClass rc = mapping.RootClasses.First(r => r.Name.Contains("Parent"));
var relation = rc.Properties.First(p => p.Name == "Children");
var collection = (HbmBag)relation;
collection.Key.ondelete.Should().Be(HbmOndelete.Noaction);
}
示例10: IntegrationWithOrmWhenCustomerIsTheMaster
public void IntegrationWithOrmWhenCustomerIsTheMaster()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass(new[] {typeof (Customer), typeof (Address)});
orm.ManyToOne<Customer, Address>();
orm.OneToOne<Address, Customer>();
var mapper = new Mapper(orm);
var mappings = mapper.CompileMappingFor(new[] { typeof(Customer), typeof(Address) });
HbmClass customer = mappings.RootClasses.Single(c=> c.Name.Contains("Customer"));
HbmManyToOne customerAddress = customer.Properties.OfType<HbmManyToOne>().Single();
customerAddress.unique.Should().Be.True();
customerAddress.cascade.Should().Be("all");
HbmClass address = mappings.RootClasses.Single(c => c.Name.Contains("Address"));
HbmOneToOne addressCustomer = address.Properties.OfType<HbmOneToOne>().Single();
addressCustomer.propertyref.Should().Be("Address");
}
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:19,代码来源:BidirectionalOneToOneForeignKeyAssociationTest.cs
示例11: WithExplicitCascadeToNone
public void WithExplicitCascadeToNone()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Parent>();
orm.TablePerClass<Child>();
orm.ManyToOne<Child, Parent>();
orm.Cascade<Parent, Child>(Cascade.None);
HbmMapping mapping = GetMapping(orm);
HbmClass rc = mapping.RootClasses.First(r => r.Name.Contains("Parent"));
var relation = rc.Properties.First(p => p.Name == "Children");
var collection = (HbmBag)relation;
collection.Cascade.Satisfy(c => string.IsNullOrEmpty(c));
}
示例12: WithExplicitCascadeToAll
public void WithExplicitCascadeToAll()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Parent>();
orm.TablePerClass<Child>();
orm.ManyToOne<Child, Parent>();
orm.Cascade<Parent, Child>(Cascade.All | Cascade.DeleteOrphans);
HbmMapping mapping = GetMapping(orm);
VerifyMapping(mapping);
}
示例13: WithoutExplicitCascade
public void WithoutExplicitCascade()
{
var orm = new ObjectRelationalMapper();
orm.TablePerClass<Parent>();
orm.TablePerClass<Child>();
orm.ManyToOne<Child, Parent>();
HbmMapping mapping = GetMapping(orm);
VerifyMapping(mapping);
}