【发布时间】:2010-01-20 21:04:58
【问题描述】:
我有一个名为 LoanApplication 的类,它设置了一个名为 Workflow 的集合属性。在映射文件中,我将工作流记录的检索顺序设置为按日期排序,因此当前工作流始终是列表中的第一项。
现在我想通过当前工作流进行查询,以使用 Criteria API 获取处于特定工作流步骤中的 LoanApplications。我真的不知道该怎么做。这是我映射工作流集合的方式:
<bag name="ApplicationWorkflow" table="PreApplication.ApplicationWorkflow" generic="true" inverse="true" order-by="StartDate DESC"
cascade="all" lazy="true">
<key column="ApplicationID" />
<one-to-many class="ApplicationWorkflow" />
</bag>
这是我检索应用程序的方式(这是我需要通过当前工作流功能添加过滤器的地方):
public IList<Model.PreApplication.Application> GetCompletedApplications()
{
IList<Model.PreApplication.Application> result = null;
using (ITransaction transaction = this.Session.BeginTransaction())
{
result = this.Session.CreateCriteria<Model.PreApplication.Application>()
.AddOrder(new Order("EnteredDate", false))
.List<Model.PreApplication.Application>();
transaction.Commit();
}
return result;
}
感谢您的帮助!
【问题讨论】:
标签: nhibernate