'Heterogeneous type mappings detected when making new array in LINQ Npgsql Dot Net 6

I upgraded my dotnet5 web api to dotnet6 since then I am getting the error Heterogeneous type mappings detected when making new array whereas the same is working in dotnet5.

Below is my query

var a = (from i in _context.Items
        join t in _context.ItemAttrs on i.itemCode equals t.itemCode into temp
        from ia in temp.DefaultIfEmpty()
        join t1 in _context.BarCodes on ia.id equals t1.itemAttrID into temp1
        from b in temp1.DefaultIfEmpty()
        select new
        {
            label = $"{i.itemDesc} | {ia.addlUoM} | {b.barCodeOrShortCode}", // working
            label2 = $"{i.itemDesc} | {ia.addlUoM} | M-{ia.mRP.ToString()}", // working
            label3 = $"{i.itemDesc} | M-{ia.mRP} | {b.barCodeOrShortCode}", // working
            label4 = $"{i.itemDesc} | {ia.addlUoM} | M-{ia.mRP} | {b.barCodeOrShortCode}", // NOT WORKING
            
            ... other props
        }).Distinct().ToList();

Here, itemDesc, addlUoM, barCodeOrShortCode are string and mRP is decimal. And b is nullable.

Any breaking change for this in dotnet6?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source