1、select a.id, sum(c.x) as totalX from .....
2、select a.* from a
inner join (....)k on a.id=k.id order by k.TotalX
关键是用linq to sql……
@素和墨如: LINQ更简单了,LINQ是支持Lazy loading的,也就是说你可以这样写
var query1= from c in TableA
join d in TableB on ...
join e in TableC on ...
select c.AID, e.x
'合计
var query2= from c in query1
group into ....
select new
{
AID= c.AID,
TotalX= sum(g.x)
}
var query3 = from c in tableA
join d in query2 on c.AID=d.AID
order by d.TotalX
select c
//分页
var query4 = (from c in query3
select c).skip(pageCount*PageSize).take(PageSize)
你说说看你哪一个LINQ不会写吧。
你主要是哪里不晓得呢,不行了就一个一个查,然后作为变量传递,因为做联合查询的话,还是原生态的sql吧,linq效果并不是很好,必经是经过处理的,如果要用sum的话sum = c.sum(x => x.a),分页的话linq里面那个take应该就是的