2010-04-13 34 views
0

我有一個映射文件NHibernate的映射+伊賽特

<set name="Friends" table="Friends"> 
    <key column="UserId"/> 
    <many-to-many class="User" column="FriendId"/> 
</set> 

我想爲朋友表這將創建指定額外的列。

例如批准(用戶必須同意好友請求)

有沒有簡單的方法?

而且更新

<?xml version="1.0" encoding="utf-8"?> 
<hibernate-mapping namespace="MyVerse.Domain" assembly="MyVerse.Domain" xmlns="urn:nhibernate-mapping-2.2"> 
    <class name="User" table="[User]" lazy="true"> 
    <id name="Id" type="Guid"> 
     <generator class="guid" /> 
    </id> 
    <property name="DateCreated" type="DateTime" not-null="true" /> 
    <property name="Deleted" type="Boolean" not-null="true" /> 
    <property name="Firstname" type="String" length="100" not-null="true" /> 
    <property name="Lastname" type="String" length="100" not-null="true" /> 
    <bag name="Friends" table="[Friend]"> 
     <key column="UserId"/> 
     <many-to-many class="Friend" column="FriendId"/> 

    </bag> 

    </class> 
    <class name="Friend" table="[Friend]" lazy="true"> 
    <id name="Id" type="Guid"> 
     <generator class="guid" /> 
    </id> 
    <property name="DateCreated" type="DateTime" not-null="true" /> 
    <property name="Approved" type="Boolean" not-null="true" /> 
    </class> 
</hibernate-mapping> 

將導致鏈接到朋友表從朋友表

回答

1

如果一套具有「額外性」,則必須將其轉換成適當的實體。

因此,User沒有ISet<User>;它有一個ISet<Friend>

+0

但是那麼朋友類會是什麼樣子呢?用戶可以將用戶作爲朋友 – jack 2010-04-13 20:13:23

+0

更新帖子 – jack 2010-04-13 20:16:57

+0

所有真正需要開心的是朋友表必須具有批准的布爾列 – jack 2010-04-13 20:27:40