1

SQL ステートメントがあり、それを LINQ に変換したいと考えています。今の問題は、LINQ でグループ化する方法がわからないことです。

これがコードです。

SQLで

select plp.ProspectsListID, p.Prospect_PII_Key 
from ProspectListProspect plp
join Prospects p
on p.ProspectsID = plp.ProspectsID
group by plp.ProspectsListID,p.Prospect_PII_Key

リンクで

  var list1 = from plp in GetDataContext.SQLDataContext.GetTable<DataAccess.ProspectListProspect>()
                    join p in     GetDataContext.SQLDataContext.GetTable<DataAccess.Prospect>()
                        on plp.ProspectsID equals p.ProspectsID
                    select new
                    {
                        ProspectID = plp.ProspectsListID,
                        Prospect_PII_Key = p.Prospect_PII_Key
                    };

ありがとう

ジェイソン

4

3 に答える 3

2

これ

var list1 = from item in
                (
                   from plp in GetDataContext.SQLDataContext.GetTable<DataAccess.ProspectListProspect>()
                join p in     GetDataContext.SQLDataContext.GetTable<DataAccess.Prospect>()
                    on plp.ProspectsID equals p.ProspectsID
                  select new
                  {
                      ProspectID = plp.ProspectsListID,
                      Prospect_PII_Key = p.Prospect_PII_Key
                   }
                )
                group item by new {item.ProspectID ,item.Prospect_PII_Key } into grp
                select new
                {
                    ProspectID = grp.ProspectsListID,
                    Prospect_PII_Key = grp.Prospect_PII_Key
                }

;

于 2012-09-28T06:48:13.747 に答える
1

これをチェックして

var list1 = from plp in GetDataContext.SQLDataContext.GetTable<DataAccess.ProspectListProspect>()
                    join p in     GetDataContext.SQLDataContext.GetTable<DataAccess.Prospect>()
                        on plp.ProspectsID equals p.ProspectsID
             Group By Key = New With {plp.ProspectsListID,p.Prospect_PII_Key} Into Group                       
             Select Group;
于 2012-09-28T03:13:31.513 に答える
1
var list1 = from plp in GetDataContext.SQLDataContext.GetTable<DataAccess.ProspectListProspect>()
            join p in  GetDataContext.SQLDataContext.GetTable<DataAccess.Prospect>()
                   on plp.ProspectsID equals p.ProspectsID
            group p by new {plp.ProspectsListID,p.Prospect_PII_Key} into g
            select new
                {
                    ProspectID = g.Key.ProspectsListID,
                    Prospect_PII_Key = g.Key.Prospect_PII_Key
                };
于 2012-09-28T06:41:53.367 に答える