English 中文(简体)
姓名不详的询问
原标题:nhibernate named query join single record

这是:

class Unit
{
   public Position ManagerPosition;
}

<sql-query name="GetUnits" read-only="true">
    <query-param name="UserGroupId" type="int"/>
    <query-param name="RelevantToDate" type="datetime"/>
    <query-param name="ParentUnitId" type="int"/>

    <return class="Unit" />
...
</sql-query>

<sql-query name="GetPositions" read-only="true">
    <query-param name="UserGroupId" type="int"/>
    <query-param name="RelevantToDate" type="datetime"/>
    <query-param name="UnitId" type="int"/>
    <query-param name="ManagersOnly" type="bool"/>

    <return class="Position" />
...
</sql-query>

<>Units and Positions are in separate table, but bothfiled by 用户组(RelevantDate(适当查询参数)。 由于财产的复杂性,这些财产没有直接绘制到表格中。

试图做的是获得一份名单,列出Units,并附上一份Position,该名单的国旗为IsManager

I ve tried to do it by return-join - no success. I ve tried to do it by

<return class="Unit">
  <return-property name="ManagerialPosition" column="position"/>
</return>

and

<return alias="position" class="Position">

但国家自由党说,它能够形成一系列系统。 反对设立一系列股。

what is better way to solve my problem? thanks in advance!

较好的方法是:

  1. call a parameterized query for Position from Unit query.
  2. parse a resultset of a combined query to get Unit and Position properties
问题回答

暂无回答




相关问题
nHibernate one-to-many inserts but doesnt update

Instead of getting into code, I have a simple question. Default behavior for a simple one-to-many is that it inserts the child record then updates the foreign key column with the parent key. Has ...

How Do I copy an existing nhibernate object as a new object?

I a persisted NHibernate object that I would like to repersist as a new entity. How do I get NHibernate to save this object as if it was a new? I am thinking I might create a session interceptor to ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

NHibernate Search in a List using ICriteria

I have my class X : public class ClassX { public virtual IList<ClassY> ListY { get; set; } ... } My ClassX mapping (using Fluent) ... HasMany<ClassX>(x => x.ListY ) ....

热门标签