简体   繁体   中英

Join Unrelated tables in Fluent Nhibernate with QueryOver or CreateCriteria

I have tables :

  • tableAnnual - AnnualAmount, AnnualCurrency. creationDate, Id
  • tableMonthly - MonthlyAmount, MonthlyCurrency, creationDate, Id
  • tableSharevalue - CurrentSharevalue, creationDate, Id
  • tableMiscDetails - clientType, clientName, MarketValueAmount, creationDate

I have now to do the following select with NHibernate and 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

Can someone give me a sample, how I can do that? - My Problem is, that I have to join multiple Tables mentioned above

Solution with NHibernate in this case, is either to use HQL

Joining two unrelated view-tables with nhibernate and ICriteria

14.2. The from clause (small cite and snippet)

Multiple classes may appear, resulting in a cartesian product or "cross" join.

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

Or create raw SQL. There is some example how to:

NHibernate - QueryOver Child rows as comma separated values

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM