Skip to content

Instantly share code, notes, and snippets.

@wullemsb
Created June 15, 2013 11:06
Show Gist options
  • Save wullemsb/5787767 to your computer and use it in GitHub Desktop.
Save wullemsb/5787767 to your computer and use it in GitHub Desktop.
Linq to Entities: apply date transformations
var chartData = from log in _contextProvider.Context.Logs
group log by new
{
ApplicationName=log.Application.Name,
Year= SqlFunctions.DatePart("Year", log.Timestamp),
Month= SqlFunctions.DatePart("Month",log.Timestamp)
}
into logsPerApplication
select new
{
Count = logsPerApplication.Count(),
logsPerApplication.Key.ApplicationName,
logsPerApplication.Key.Year,
logsPerApplication.Key.Month
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment