llbl gen group by with conditional sum could not bound an Error

82 Views Asked by At

I am using linq query with llblgen and it's give me an error, anyone can please help me to resolved this issue. This is my query

var reuslt = from cc in _metadata.TableName
                                     where cc.StdId == 125
                                     group cc by new { cc.Column1, cc.Column2 } into gr
                                     select new
                                     {
                                         Col1 = gr.Key.Column1,
                                         Col2 = gr.Key.Column2,
                                         IncomeType1 = gr.Sum(x => x.TypeId == 1 ? x.MonthlyIncome : 0),
                                         IncomeType2 = gr.Sum(x => x.TypeId == 2 ? x.MonthlyIncome : 0)
                                     };

And Error that occuring in this query when i do result.ToList() Error:

The multi-part identifier "LPLA_3.TypeId" could not be bound.
The multi-part identifier "LPLA_3.MonthlyIncome" could not be bound.

This is data

Id       stdId            column1      column2            TypeId      MonthlyIncome
1         125               1234          12                1                 4
2         125               1235          12                2                 4

Expected Output should be

StdId   column1  column2  TypeId1  TypeId2     IncomeType1       IncomeType2 
125      1234      12        1       2             4                4

please help me

0

There are 0 best solutions below