0

それからLinqクエリを作成する方法を教えてください。

SELECT 
[GroupBy1].[K1] AS [AccountName], 

[GroupBy1].[K2] AS [LeadBy], 

[GroupBy1].[K3] AS [Status], 

[GroupBy1].[K3] AS [Industry], 

[GroupBy1].[A1] AS [C2]

FROM ( SELECT 
    [Extent1].[AccountName] AS [K1],

     [Extent2].[LeadBY] AS [K2],

     [Extent2].[Status] AS [K3],

     [Extent2].[Industry] AS [K4],

    COUNT(1) AS [A1]

    FROM [dbo].[Opportunities] AS [Extent1]

    join [dbo].[Leads] AS [Extent2]

    on [Extent1].[AccountName] IS NOT NULL

    AND [Extent1].[AccountName]=[Extent2].[AccountName]

    GROUP BY [Extent1].[AccountName],[Extent2].[Leadby],[Extent2].[Status],[Extent2].
[Industry]
)  AS [GroupBy1]
4

2 に答える 2

0

AccountName 列につながる外部キーがない場合は、マッピングに依存します。これを試してください。

from i in Context.Opportunities
join l in Context.Leads on l.AccountName equals i.AccountName
group i by new { i.AccountName, l.LeadBY, l.Status, l.Industry } into g
select new
{
    g.Key.AccountName,
    g.Key.LeadBY,
    g.Key.Status,
    g.Key.Industry,
    Count = g.Count();
}

AccountName 列につながる外部キーがある場合は、これを試してください。

from i in Context.Opportunities
group i by new { i.AccountName, l.Lead.LeadBY, l.Lead.Status, l.Lead.Industry } into g
select new
{
    g.Key.AccountName,
    g.Key.LeadBY,
    g.Key.Status,
    g.Key.Industry,
    Count = g.Count();
}
于 2012-12-13T17:01:18.050 に答える
0

このプログラムを使用してみてください: http://www.linqpad.net/基本的な操作と高度な操作の例があります。他のチュートリアルもダウンロードできます。

于 2012-12-13T04:47:54.583 に答える