NHibernate 對分組聚合支援的不好

2021-09-06 02:39:42 字數 894 閱讀 7526

hibernate 對分組聚合支援的不好,例如下面的**:

var query = from raqi in session.query()

group raqi by raqi.spacekey

into g

select new ;

這樣的查尋生成的sql如下,很明顯是錯誤的,

select

factstatra0_.[spacekey] as col_0_0_,

cast(count(*) as int) as col_1_0_

from

[dbo].[factstatraqi] factstatra0_

group by

factstatra0_.[spacekey]

linqtosql可以生成正確的sql

-- region parameters

declare @p0 float set @p0 = 1

-- endregion

select [t1].[spacekey] as [key], (

select count(*)

from [factstatraqi] as [t2]

where ([t2].[raqi] > @p0) and ([t1].[spacekey] = [t2].[spacekey])

) as [count]

from (

select [t0].[spacekey]

from [factstatraqi] as [t0]

group by [t0].[spacekey]

) as [t1]

看來,nh的linq查尋還有很長的路要走。

Nhibernate 的聚合函式

今天遇到的問題 hql select max sninfo.ln from sninfo 設定maxresult 1 執行這條查詢時,返回的是sninfo物件,其中ln是519,query的返回結果集也不是1。改為iquery q corerepository.activesession.creat...

pandas 分組聚合

綜合使用 資料鏈結 統計每個國家的星巴克的數量 按照單字段聚合 codeing utf 8 import pandas as pd import numpy as np df pd.read csv data starbucks store worldwide.csv 按國家進行分組後會有很多列 然...

mysql中對分組內容排序

id group sort11 1212 3224 2151 3表sort group如上圖所示,要求 選取每組中最大值。方法1 select a.group,substr group concat sort order by sort desc from 1 for 1 maxsort from ...