Multiple Sorting with GroupJoin is not working as expected

  • Thread starter Thread starter Sunilsharma
  • Start date Start date
S

Sunilsharma

Guest
Hi All,

It may sound bit weird however i am facing issue with a basic operation in gropujoin.

I have tow Lists, List1 and List2. List 1 is very large list with morethan 250 properties.

I want to get my List 1 sorted with 2 fields of List 2 and 1 field from List1. Both the list has a common field.

following is my join code

var result= List1.GroupJoin(List2, l=> l.commonField, r=> r.commonField,
(x, y) => new
{
List1Obj= x,
List2SelectedFields= y.Select(wc => new { wc.OrderField1, wc.commonField}).FirstOrDefault()
}).OrderBy(x => x.List2SelectedFields.OrderField1)

.ThenBy(x => x.List2SelectedFields.commonField)

.ThenBy(x => x.List1Obj.sortField)
.Select(x => x.List1Obj).ToList();

I have checked the same code with different sample where it works fine.

Both the list were Observable Collections however i am converting them to List before groupjoin.

Can someone help me on am i missing anything?

Thank You!





Best Regards, Sunil Sharma

Continue reading...
 
Back
Top