gpt4 book ai didi

c# - Linq SQL GroupJoin 错误

转载 作者:行者123 更新时间:2023-11-30 16:45:26 24 4
gpt4 key购买 nike

这是我的代码显示的错误

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();

基于GroupJoin位置的错误显示以及如何加入这种Left Join

最佳答案

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();

关于c# - Linq SQL GroupJoin 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42159815/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com