使用nHibernate进行多对多分页

时间:2012-05-10 04:06:36

标签: nhibernate fluent-nhibernate many-to-many fluent-nhibernate-mapping nhibernate-criteria

当我处于TransactionYear desc上的单个成员对象(在Transaction表上并按MemberTransReltn表上的RoleType进行过滤)时,我无法弄清楚如何翻阅事务记录。

  • 会员 - 会员ID 名字 姓 等....

  • MemberTransReltn - 会员ID TRANSACTIONID 角色类型

  • 交易 - TRANSACTIONID TransactionName TransactionYear 等.....

    **** Member Mapping *****
    mapping.HasMany(x => x.MemberTransactions)
     .Table("UserTransReltn")
     .Cascade.AllDeleteOrphan()
     .Fetch.Join()
     .Inverse()
     .KeyColumn("UserId");
    
    ***** Relationship Table ******
    mapping.Table("UserTransReltn");
    mapping.Map(x => x.MemberId, "UserId");
    mapping.Map(x => x.TransactionId, "TransactionId");
    mapping.Map(x => x.RoleTypeId); 
    mapping.IgnoreProperty(x => x.Member);
    mapping.IgnoreProperty(x => x.TransactionSet);
    
    mapping.CompositeId()
       .KeyProperty(x => x.MemberId, "UserId")
       .KeyProperty(x => x.TransactionId, "TransactionId");
    
    mapping.Map(x => x.RoleTypeId).Column("RoleTypeInt");
    
    
    **** Transaction Mapping *****
    mapping.Table("Transactions");
    mapping.Id(x => x.TransactionId).Column("TransactionId"); 
    mapping.HasMany(x => x.MemberTransactions)
    .Table("UserTransReltn")
       .Cascade.AllDeleteOrphan()
       .Fetch.Join()
       .Inverse()
       .KeyColumn("TransactionId");
    

0 个答案:

没有答案