Mego开发文档 - 复杂查询
Posted CarefreeXT
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Mego开发文档 - 复杂查询相关的知识,希望对你有一定的参考价值。
复杂查询
Mego 还支持一些更高级的LLINQ查询写法,本文只列出一部分。
分组汇总查询
using (var db = new OrderManageEntities())
{
var query = from a in db.Products
group a by a.Category into g
select new
{
g.Key,
Count = g.Count(),
Max = g.Max(a => a.Id)
};
var data = query.ToArray();
}
分组查询及分页
using (var db = new OrderManageEntities())
{
var query = (from a in db.Products
group a by a.Category into g
select new
{
g.Key,
List = g
})
.Skip(2).Take(2);
var data = query.ToArray();
}
连接分组查询
using (var db = new OrderManageEntities())
{
var query = from a in db.Orders
join b in db.OrderDetails on a.Id equals b.OrderId into g
select new
{
Order = a,
MaxId = g.Max(m => m.Id)
};
var data = query.ToArray();
}
连接分组查询及分页
using (var db = new OrderManageEntities())
{
var query = (from a in db.Orders
join b in db.OrderDetails on a.Id equals b.OrderId into g
select new
{
Order = a,
List = g
})
.Skip(5).Take(5);
var data = query.ToArray();
}
以上是关于Mego开发文档 - 复杂查询的主要内容,如果未能解决你的问题,请参考以下文章