mnichols wrote:
I'd go back and reread those docs. The inheritance strategies outlined are not constraining you to have all methods/props in a single class, but rather is proposing different ways of mapping the object representation to the flattened relational model (table(s)).
Thanks for your answer. I reviewed documentation again but didn't find answer. You suggest me the solution with discriminator but it's not suitable for me because I do not have discriminating value. I'll explain why:
Let's assume that you have class "User" which contains user information. In one of a form you need to show users list with their rate e.g. "formula" field from another table (COUNT(*) FROM UserRate where userid = :user). I do not want to know user rate everytime but only on this form.
The possible solution is to declare the class property one more time. But it would be great if I can somehow "extend" current class with another.
e.g.:
<code>
<class name="User, ..." table="dbo.[user]" lazy="false">
<id name="UserId" column="user_id" type="Int32" unsaved-value="0">
<generator class="native"/>
</id>
<property column="user_phone" type="String" name="UserPhone" length="150" />
<property column="user_email" type="String" name="UserEmail" length="150" />
<property column="user_status_id" type="Int32" name="UserStatusId" not-null="true" />
<property column="user_name" type="String" name="UserName" length="50" />
</class>
<class name="UserWithRate" inheritedClass="true">
<property name="Rates" formula="(SELECT COUNT(*) FROM UserRate AS cb WHERE cb.UserID = UserId)" />
</class>
class User
{
...
}
class UserWithRate : User
{
int Rates { ... }
}
</code>