【问题标题】:Join Unrelated tables in Fluent Nhibernate with QueryOver or CreateCriteria在 Fluent Nhibernate 中使用 QueryOver 或 CreateCriteria 连接不相关的表
【发布时间】:2015-09-25 05:03:05
【问题描述】:

我有桌子:

  • tableAnnual - 年度金额、年度货币。创建日期,ID
  • tableMonthly - MonthlyAmount、MonthlyCurrency、creationDate、Id
  • tableSharevalue - CurrentSharevalue、creationDate、Id
  • tableMiscDetails - clientType、clientName、MarketValueAmount、creationDate

我现在必须使用 NHibernate 和 QueryOver 进行以下选择:

Select tableAnnual.AnnualAmount, tableAnnual.AnnualCurrency, 
tableMonthly.MonthlyAmount, MonthlyAmount.MonthlyCurrency,
tableSharevalue.CurrentSharevalue, tableMiscDetails.clientType, tableMiscDetails.clientName, tableMiscDetails.MarketValueAmount
from tableAnnual
outer join tableMonthly on tableAnnual.creationDate  = tableMonthly.creationDate
outer join tableSharevalue on tableMonthly.creationDate = tableSharevalue.creationDate
outer join tableMiscDetails on tableSharevalue.creationDate = tableMiscDetails.creationDate
Where id = 123456

谁能给我一个样品,我该怎么做? - 我的问题是,我必须加入上面提到的多个表

【问题讨论】:

    标签: c# join nhibernate fluent-nhibernate queryover


    【解决方案1】:

    在这种情况下使用 NHibernate 的解决方案是使用 HQL

    Joining two unrelated view-tables with nhibernate and ICriteria

    14.2. The from clause (small cite and snippet)

    可能会出现多个类,从而导致笛卡尔积或“交叉”连接。

    from Formula, Parameter
    from Formula as form, Parameter as param
    

    或者创建原始 SQL。有一些示例如何:

    NHibernate - QueryOver Child rows as comma separated values

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多