我想通过左连接group by each的结果值来获得值。
var mgga = mggb.GroupBy(i => i.GoodsCode).Select(i => i.MaxBy(x => x.PriceChangeDate));
var oega = oegb.GroupBy(i => i.GoodsCode).Select(i => i.MinBy(x => x.EventSalePrice));
像这样加入,
var result = from mgg in mgga
join oeg in oega
on new { storeCode = mgg.StoreCode, goodsCode = mgg.GoodsCode } equals new { storeCode = oeg.StoreCode, goodsCode = oeg.GoodsCode } into mgoe
from oeg in mgoe.DefaultIfEmpty()
select new {
GoodsCode = mgg.GoodsCode,
};
但是,这显示错误消息。
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: The LINQ expression 'g
.AsQueryable()
.Select(e => new {
...
})
.AsQueryable()
.MaxBy(x => x.PriceChangeDate)' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'.
我如何加入类型为IQueryable〈'a〉的mgga或oga?
1条答案
按热度按时间jqjz2hbq1#
尝试以下查询实现。其他部分应该可以工作。