Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq SQL GroupJoin Error

Here is my code display an error like

Severity Code Description Project File Line Suppression State Error CS0411 The type arguments for method Queryable.GroupJoin<TOuter, TInner, TKey, TResult>(IQueryable<TOuter>, IEnumerable<TInner>, Expression<Func<TOuter, TKey>>, Expression<Func<TInner, TKey>>, Expression<Func<TOuter, IEnumerable<TInner>, TResult>>) cannot be inferred from the usage. Try specifying the type arguments explicitly

data.RawMaterail.Where(c => c.Category.categoryType == 1)
                .Join(data.Sizes, x => x.DiamondSize.diamondSizeId, 
                                  y => y.DiamondSize.diamondSizeId, 
                                  (x, y) => new { RM = x, Size = y })
                .GroupJoin(data.PriceLevels.Where(c => c.priceLevelId == PriceLevelId), 
                           x => new { x.RM.rMId , x.Size.sizeId}, 
                           y => new { y.rmId , y.sizeId}, 
                           (y, x) => new { Category = y, PurityLevel = x })
                .SelectMany(xy => xy.PurityLevel.DefaultIfEmpty(), 
                           (x, y) => new { Category = x.Category, PurityLevel = y })
                .Select(item => new
                 {
                     Code = item.Category.RM.rMCode + " " + item.Category.Size.sizeName,
                     Name = item.Category.RM.rMName + " " + item.Category.Size.sizeName,
                     Date = item.PurityLevel.rowDate,
                     Id = (int)item.Category.RM.rMId,
                     RateId = (int?)item.PurityLevel.stonePriceLevelId ?? 0,
                     Price = (double?)item.PurityLevel.price ?? 0,
                     PriceLevelId = (int?)item.PurityLevel.priceLevelId ?? 0,
                     TypeId = (int)item.Category.Size.sizeId,
                     IsRateChanged = false
                 }).OrderBy(c => c.Date).ThenBy(n => n.TypeId).ToList();

The error display based on GroupJoin position and how can join this type of Left Join

like image 401
Sam Avatar asked Aug 16 '26 17:08

Sam


1 Answers

data.RawMaterail.Where(c => c.Category.categoryType == 1)
                .Join(data.Sizes, x => x.DiamondSize.diamondSizeId, 
                                  y => y.DiamondSize.diamondSizeId, 
                                  (x, y) => new { RM = x, Size = y })
                .GroupJoin(data.PriceLevels.Where(c => c.priceLevelId == PriceLevelId), 
                           x => new { RID = (int?)x.RM.rMId , SID = (int?)x.Size.sizeId}, 
                           y => new { RID = (int?)y.rmId , SID = (int?)y.sizeId}, 
                           (y, x) => new { Category = y, PurityLevel = x })
                .SelectMany(xy => xy.PurityLevel.DefaultIfEmpty(), 
                           (x, y) => new { Category = x.Category, PurityLevel = y })
                .Select(item => new
                 {
                     Code = item.Category.RM.rMCode + " " + item.Category.Size.sizeName,
                     Name = item.Category.RM.rMName + " " + item.Category.Size.sizeName,
                     Date = item.PurityLevel.rowDate,
                     Id = (int)item.Category.RM.rMId,
                     RateId = (int?)item.PurityLevel.stonePriceLevelId ?? 0,
                     Price = (double?)item.PurityLevel.price ?? 0,
                     PriceLevelId = (int?)item.PurityLevel.priceLevelId ?? 0,
                     TypeId = (int)item.Category.Size.sizeId,
                     IsRateChanged = false
                 }).OrderBy(c => c.Date).ThenBy(n => n.TypeId).ToList();
like image 116
Sam Alex Avatar answered Aug 18 '26 06:08

Sam Alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!