Linq2CSLA: Group By Into not working in BusinessListBase

Linq2CSLA: Group By Into not working in BusinessListBase

Old forum URL: forums.lhotka.net/forums/t/7148.aspx


amselem posted on Monday, June 22, 2009

I'm running latest CSLA 3.6.3 and found that this expression returns Nothing:

Dim MyGroupedData = From lin In MyBusinessListBase _
Group By lin.PKey Into g = Group


This is what I found if it may help:

It looks like that this linq expression maps to this function:
_
Public Shared Function GroupBy(Of TSource, TKey) ( _
source As IEnumerable(Of TSource), _
keySelector As Func(Of TSource, TKey), _
comparer As IEqualityComparer(Of TKey) _
) As IEnumerable(Of IGrouping(Of TKey, TSource))


CslaQueryProvider fails to map at the MethodsEquivalent function the third parameter (IEqualityComparer) and the whole expression returns nothing.

According to MSDN: "If comparer is a null reference (Nothing in Visual Basic), the default equality comparer Default is used to compare keys.", maybe we can handle this as a special case and send Nothing?

AaronErickson replied on Monday, June 22, 2009

Thanks for finding this - I will take a look over the next couple days and see if we can handle this as a special case. I would be curious why the mapping does not occur - maybe I can find that and not have to do a special case.

-A

amselem replied on Tuesday, July 28, 2009

Hi again Aaron. Any updates on this one?

I'm still having issues when grouping BLB using the posted syntax :(

MikeH replied on Thursday, October 22, 2009

Having same issue ... is there any resolution? Thanks

amselem replied on Friday, October 23, 2009

AFAIK there’s no resolution, but you could workaround using this syntax:

Dim MyGroupedData = (From lin In MyBusinessListBase). _
GroupBy(Function(x)(x.PKey))

AaronErickson replied on Tuesday, October 27, 2009

This is what I recommend for now... sorry I lost track of this thread, but I plan to look into this this week.

AaronErickson replied on Sunday, November 01, 2009

Hi there-

I just committed a test into the csla 3.8 branch to exercise this.  It is not failing, but if you have a chance, maybe see what I am doing to see if perhaps there is some variation that you are doing in your case that might change things.

If you give me an updated test that manages to fail, it will expedite things.

Also, there is a good chance that this got fixed with one of the interim releases.  A lot of detail work has been done with the methodmapper that fixed a number of grouped issues, including possibly this one.

Copyright (c) Marimer LLC