score:0
Check the code mentioned in my question: Group by Weeks in LINQ to Entities. It shows how you can group your data by days and months. Let me know if you have any other questions.
score:0
This is probably a bug in MySQL connector. My solution for that was to place .ToList()
just before .GroupBy()
.
score:1
Func<DateTime, object> groupByClause;
if (groupByDay) groupByClause = date => date.Date;
else if (groupByMonth) groupByClause = date => new { date.Year, date.Month};
else throw new NotSupportedException("Some option should be chosen");
var result = data.Where(d => d.Type == "Deposit")
.GroupBy(groupByClause)
.Select(g => new { DateKey = g.Key,
TotalDepositAmount = g.Sum(d => d.Amount),
DepositCount = g.Count(),
});
Of course this should be checked whether linq-2-entities will accept it.
Source: stackoverflow.com
Related Query
- Linq to Entity Group by Date
- Linq / Entity Framework - how to group by date with range
- Entity Framework select one of each group by date
- how to use entity framework to group by date not date with time
- Linq Getting Customers group by date and then by their type
- Entity Framework - Linq query with order by and group by
- .NET LINQ to entities group by date (day)
- Entity Framework Group By with Max Date and count
- Linq to Entity get a Date from DateTime
- C# get minute number from date in linq group by
- Linq get sum of data group by date
- Filling in missing dates using a linq group by date query
- Group by date range , count and sort within each group LINQ
- Linq to Entity Join and Group By
- Linq Group By not taking inner entity
- Left join after a into group in Linq using entity framework (core)
- LINQ Source Code Available
- how do i use group by only on date from datetime in LINQ query
- Use LINQ to group a sequence by date with no gaps
- Get latest record and group with highest date - LINQ
- C# Linq or Lambda expression Group by Week IEnumerable list with date field
- MySQL entity framework Group and Select By Date
- C# linq group by on different keys in the same entity
- LINQ to select a column with max date from a group
- LINQ group by date descending, and order by time ascending
- Linq / Entity Group by then count those groups
- How to use Linq group a order list by Date
- creating Linq to sqlite dbml from DbLinq source code
- Select Max Date items in group using Linq VB.NET
- Linq group by date when using multiple group by fields
More Query from same tag
- find control by name with linq
- LINQ to extract duplicate data more than 3
- Linq to Entities Query -
- LINQ to XML + left join + group by = fail
- Filtering large collection of Unknown type
- Returning the innerlist from a custom collection inheriting from List<T>
- How to: Select Distinct objects<T> from multiple Lists<T> with 1 or more properties of same type
- Linq SUM values error
- Replace All char in a string of an object in a list c#
- Linq Intermediate Object in method chain for Where and Select?
- Parsing through xml page with c#
- Linq to sql - get value from db function and not directly from the db field (while mapping properties)
- Converting IEnumerable<IEnumerable<T>> to List<string>
- bind linq expression
- Does not exist in the current context
- Matching XML elements to ListBox selected item - C#
- Creating JSON object from Ienumerable using LINQ
- Linq to SQL " 2 Query "
- XElement.Decendents.First not finding xml field
- How to split a string using LINQ
- Apply MemberExpression to an object to retrieve Property value
- How do I get a list of all properties including those within nested objects within a class file
- help with linq query
- Entity Framework Linq 1 to many query
- Asp Mvc How to assign joined query value to viewmodel?
- How to implement SelectMany in System.Linq.Dynamic ExpressionParser
- Entity Framework 4 - List<T> Order By based on T's children's property
- Concatenate an IEnumerable of IEnumerables?
- Linq assign values from one table into another
- Getting a continuous chain of values based on a condition in LINQ