Reputation: 47
How do I translate the following SQL statement into L2S?
SELECT DefaultCode, MAX(EffectiveDt) AS EffectiveDt
FROM tblDF_DefaultSetting
GROUP BY DefaultCode
Upvotes: 2
Views: 119
Reputation: 77546
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) });
Upvotes: 4