GroupBy造成麻烦

时间:2018-02-27 15:33:53

标签: c# entity-framework linq linq-to-sql

我有一个DataGridView,我必须填写一个查询,这是我的查询:

from Per in db.personne
join Dep in db.deplacement_personne 
on new { deplacement_personne = Per.num_personne } equals new { 
deplacement_personne = Dep.num_personne } into depPersAssign
from depPers in depPersAssign.DefaultIfEmpty()
where !(from Dep in db.deplacement_personne where Dep.id_deplacement == 
numDeplacement select Dep.num_personne).Contains(Per.num_personne)
select Per

我不知道如何组建一个' groupBy'。我尝试了什么:

from Per in db.personne
join Dep in db.deplacement_personne 
on new { deplacement_personne = Per.num_personne } equals new { 
deplacement_personne = Dep.num_personne } into depPersAssign
from depPers in depPersAssign.DefaultIfEmpty()
where !(from Dep in db.deplacement_personne where Dep.id_deplacement == 
numDeplacement select Dep.num_personne).Contains(Per.num_personne)
group Per by Per.num_personne into pers
select Per

我需要一个对象列表(我的实体),如下所示:List<myEntity>

没有groupby,一切都很顺利,有没有办法轻松做到这一点?

谢谢你

0 个答案:

没有答案