我已经创建了一个组合键,它正在工作,但理想情况下,我希望行类中单独的直接字段。NHibernate复合键
我这样做目前的方法如下:
private UserPrimaryKey _compositeKey;
public virtual UserPrimaryKey CompositeKey
{
get
{
if (_compositeKey == null) _compositeKey = new UserPrimaryKey();
return _compositeKey;
}
set {
if (_compositeKey == value) return;
_compositeKey = value;
Host = value.Host;
UserAccount = value.User;
}
}
public string Host { get; set; }
public string UserAccount { get; set; }
,我想知道是否有这样做的没有更好的办法?可能在NHibernate配置文件中。
我现在的配置文件是follwoing:
<class name="TGS.MySQL.DataBaseObjects.DataBasePrivilege,TGS.MySQL.DataBaseObjects" table="user">
<composite-id name="CompositeKey" class="TGS.MySQL.DataBaseObjects.UserPrimaryKey, TGS.MySQL.DataBaseObjects">
<key-property name="Host" column="Host" type="string" length="60" />
<key-property name="User" column="User" type="string" length="16" />
</composite-id>
</class>
实际工作:O – 2010-04-24 20:49:18
当然它!我不会骗你:-D – 2010-04-25 00:11:15
谢谢! :D它工作 – 2010-04-26 08:10:43