I had a simple Linq query:
var retVal = readModel
.GroupBy(x => x.Service)
.Select(
grp => new GroupView
{
GroupName = grp.Key,
GroupItems = grp.Sum(k => k.NumberOfItems)
}
);
retVal
was an IQueryable<GroupView>
. So far so good, what I'm trying to do is make this query dynamic, so user can use custom grouping strategies.
This is my first attempt:
var retVal = readModel
.GroupBy("Service", "it")
.Select("it.key");
And this give me an array of string containing the name of group. This is fine, but the result that I'm trying to achieve is quite far since I have two unanswerd question:
- How can I translate results to the
GroupView
model - How can I make that sum?