References
External links
MiniTool Partition Wizard Server
Category:Disk usage analysis software
Category:Computer partitioning software
Category:Windows-only softwareQ:
GroupBy, Sum and Count with paging
How do you add an element to this query.
I want to group the query by category, and total the price for each category, then use paging.
Current Code:
var data = Session.Query()
.Where(x => x.Item.ItemCode == ctx.Item.ItemCode)
.GroupBy(x => x.Category)
.Select(g => new
{
Category = g.Key,
Count = g.Count(),
Total = g.Sum(x => x.UnitPrice)
}).ToList();
Update
I tried adding an element after the group by:
.Select(g => new
{
Category = g.Key,
Count = g.Count(),
Total = g.Sum(x => x.UnitPrice),
Price = g.Sum(x => x.UnitPrice)
}).ToList();
This failed with the error:
Error 1 The type arguments for method 'System.Linq.Enumerable.Select
(System.Collections.Generic.IEnumerable, System.Collections.Generic.IEnumerable,
Func)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
A:
You need to add the whole new part like this.
var data = Session.Query()
.Where(x => x.Item.ItemCode == ctx.Item.ItemCode)
.GroupBy(x => x.Category) be359ba680
Related links:
Comments