Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用NHibernate查询器按区间分组_C#_Linq_Nhibernate_Group By_Intervals - Fatal编程技术网

C# 使用NHibernate查询器按区间分组

C# 使用NHibernate查询器按区间分组,c#,linq,nhibernate,group-by,intervals,C#,Linq,Nhibernate,Group By,Intervals,如何修改以下查询以在没有LINQ的情况下进行分组 public class Entity { public long Time { get; set; } } public IEnumerable<Entity> Query(long interval) { using (var session = m_sessionManager.OpenSession()) { return session.QueryOver<Entity>

如何修改以下查询以在没有LINQ的情况下进行分组

public class Entity
{
    public long Time { get; set; }
}

public IEnumerable<Entity> Query(long interval)
{
    using (var session = m_sessionManager.OpenSession())
    {
        return session.QueryOver<Entity>()
            .Where( /* complex query */ )
            .List()
            .GroupBy(e => e.Time / interval)
            .Select(e => e.First());
    }
}

很难理解您希望从查询中得到什么。如果您发布要在QueryOver API中编写的sql查询,效果会更好。 但我希望这能帮助你:

return session.QueryOver<Entity>()
            .Where( /* your complex query */)
            .SelectList(list => list
                .SelectGroup(e => e.Time / interval)
                .SelectSum(e => e.whatever))
                .List</*what do you want to select a list of what*/>()
                .Select( e=> e.First ) //what is First and why it is with() is it a property??
                .ToList<...>();

您可以使用

做很多事情。很难理解您希望从查询中得到什么。如果您发布要在QueryOver API中编写的sql查询,效果会更好。 但我希望这能帮助你:

return session.QueryOver<Entity>()
            .Where( /* your complex query */)
            .SelectList(list => list
                .SelectGroup(e => e.Time / interval)
                .SelectSum(e => e.whatever))
                .List</*what do you want to select a list of what*/>()
                .Select( e=> e.First ) //what is First and why it is with() is it a property??
                .ToList<...>();

你可以用它做很多事情

你想怎么做?HQL,直接SQL,?我可以用QueryOver API来做吗?忽略我。我没有正确阅读题目。你想怎么做?HQL,直接SQL,?我可以用QueryOver API来做吗?忽略我。我没有正确阅读题目。