如何创建具有子选择、分组依据和三个值的 NHibernate 查询

问题描述 投票:0回答:0

我有两个存储事件的实体类/表。现在我想创建一个按开始时间、结束时间和间隔分组的统计数据。

SQL 看起来像这样:

select Value, Block, Count(*) as Count from 
    (select p.Value, DATEDIFF(s, Convert(datetime2, '2022-03-01 10:00:00', 120), e.Timestamp) / 86400 as Block
        from SystemEventProperties p inner join SystemEvents e on p.EventId = e.Id
        where e.Timestamp >= Convert(datetime2, '2022-03-01 10:00:00', 120)
        AND e.Timestamp <= Convert(datetime2, '2023-03-30 10:00:00', 120)
        AND p.Name = 'Chute' 
        AND e.Name = 'ArticleSorted'
        ) as innerTmp
group by Value, Block
order by Value, Block

本例中的值86400为区间

我无法让 NHibernate 像在 SQL Management Studio 中那样给我结果。

谁能给我提示?

nhibernate
© www.soinside.com 2019 - 2024. All rights reserved.