I have created a composite key, and it is working, but ideals I would like the separate directly fields in the row class.
The current way I'm doing this is the following:
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; }
And i was wondering if there is any better way of doing this? Possibly in NHibernate config file.
My current config file is the 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>