如何修改以下查询以在没有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());
}
}
答案 0 :(得分:0)
很难理解你想从查询中得到什么,如果你发布要在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<...>();
可以做很多事情