Main.xaml: Cannot assign from type 'System.Collections.Generic.IEnumerable`1[System.Collections.Generic.IEnumerable`1[System.Int32]]' to type 'System.Collections.Generic.IEnumerable`1[System.Linq.IGrouping`2[System.Int32,System.Int32]]' in Assign activity 'Assign'.
However when using method query there is no error and the return type is correct:
I always hate the FROM Syntax, I mean in general the VB.NET Syntax is pretty poor compared to C#
Since the method syntax clearly works, and I think we can usually trust the compiler, I would hazard a guess the FROM Syntax is wrong, you sure you need the SELECT grp at the end? That feels like a Select() query at the end which would turn it into an iEnumerable.
Yes the SELECT is not necessary but if I omit the SELECT at the end the error turns into this:
Error ERROR Validation Error BC36754: 'IEnumerable(Of <anonymous type: Key a As Integer, Key grp As IEnumerable(Of Integer)>)' cannot be converted to 'IEnumerable(Of IGrouping(Of Integer, Integer))' because '<anonymous type: Key a As Integer, Key grp As IEnumerable(Of Integer)>' is not derived from 'IGrouping(Of Integer, Integer)', as required for the 'Out' generic parameter 'T' in 'Interface IEnumerable(Of Out T)'. The selected value is incompatible with the property type. Main.xaml
The compiler cant infer the IGROUPING when query syntax is used for some reason. I also tried with a c# project and the same error occurs.
EDIT: In the c# version of the query it actually works. The compiler can infer IGROUPING. So vb is the culprit.
Another argument in my opinion to skip the Query syntax
But yeah, then that Select is changing the data type so the compiler is correct to fuss.
I am sure if you cast the data type it could solve the issue in Query Syntax, but I’d still argue to use the method syntax, which imo is better. Personal preference of course.
Yes thank you for guiding me in the right direction. I just tested the c# query again and it worked. Do you know why the SELECT clause changes the type in VB? In C# using select or omitting it doesnt change the data type at all Its IGROUPING in both cases.