开发者

Convert SQL statement to Linq-2-Sql

How do I translate the following SQL statement into L2S?

SELECT DefaultCode, MAX(Effect开发者_如何学编程iveDt) AS EffectiveDt
FROM tblDF_DefaultSetting
GROUP BY DefaultCode


You want to use the GroupBy operator on DefaultCode and use the Select operator to create a new anonymous type with the two values you're interested in.

dataContext.tblDF_DefaultSetting
    .GroupBy(x => x.DefaultCode)
    .Select(x => new { DefaultCode = x.Key, EffectiveDt = x.Max(x => x.EffectiveDt) });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜