tags:

views:

48

answers:

2

How can I do this conversion? Is it possible with some simple LINQ query?

+1  A: 

If V is some other type not involved in the query, you can use the let keyword to create an instance and then group on it...

from x in Y
let v = new V(x.Whatever)
group v by v.Whatever into vGroup
select vGroup
Will
A: 

Assuming that V inherits from U and you want to cast each U to a V :

IEnumerable<IGrouping<string, U>> groupingsOfU =
    from u in listOfU
    group u by u.Foo;

IEnumerable<IGrouping<string, V>> groupingsOfV =
    from g in groupingsOfU
    from u in g
    group (V)u by g.Key;
Thomas Levesque