0
私のプロジェクトでは、永続性フレームワークとしてNHibernateを使用しています。データベースでは、Userという名前のテーブルとrecipeという子のテーブルがあります(すべてが別々のhbm.xmlファイルに正しくマップされています) 。 これは、「ユーザー」のxmlです:袋のプロパティによるNHibernateの注文
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="MyProject.Engine.Domain.User,MyProject.Engine" table="Users" lazy="true">
<id name="UserID" column="UserID">
<generator class="native" />
</id>
<property name="Firstname" column="Firstname" type="string" not-null="true" length="255" />
<property name="Lastname" column="Lastname" type="string" not-null="true" length="255" />
<property name="Email" column="Email" type="string" not-null="true" length="255" />
<property name="Phone" column="Phone" type="string" not-null="true" length="30" />
<property name="Birthday" column="Birthday" type="date" not-null="true"/>
<property name="Address" column="Address" type="string" not-null="true" length="255" />
<property name="City" column="City" type="string" not-null="true" length="50" />
<property name="Zipcode" column="Zipcode" type="int" not-null="true" length="32" />
<property name="Province" column="Province" type="string" not-null="true" length="30" />
<one-to-one name="Receipt" cascade="all" property-ref="UserID" class="MyProject.Engine.Domain.Receipt,MyProject.Engine" />
</class>
</hibernate-mapping>
領収書オブジェクトは、金額と呼ばれる性質を持っていると私は、そのプロパティを使用してレコードで注文します。現在、私は「ユーザー」エンティティ(es:電子メール、電話)を使用してレコードで注文することができます。 リンクされたエンティティのプロパティを使用しようとすると、エラーが発生します。どうすればそれを参照できますか?
これは私のレコードを取得し、注文する私の方法です:
public PagedList<User> GetAll(int pageIndex, int pageSize, string orderBy, string orderByAscOrDesc)
{
using (ISession session = NHibernateHelper.OpenSession())
{
var users = session.CreateCriteria(typeof (User));
if (!string.IsNullOrEmpty(orderBy))
users.AddOrder(orderByAscOrDesc.ToLower() == "asc" ? Order.Asc(orderBy) : Order.Desc(orderBy));
return users.PagedList<User>(session, pageIndex, pageSize);
}
}