gpt4 book ai didi

c# - 林奇 : Error using multiple from and Join

转载 作者:行者123 更新时间:2023-11-30 18:40:37 25 4
gpt4 key购买 nike

以下 LINQ:

var result = from u in db.userdetails
from b in db.bids
join x in db.Others on b.UserId equals x.UserId into others
from o in others.DefaultIfEmpty()
from p in db.Products
where u.UserID.Equals(b.UserId)
&& p.BidId.Equals(b.BidId)
&& b.DocId == id

给我错误:

The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'GroupJoin'.

最佳答案

通过重新组织您的 join 和 where 子句,您可能会有更好的运气(和更易于维护的代码)。使用 LINQ 实现,您不必总是在所有 from 子句之后都有 where 子句:

var result = 
from u in db.userdetails
join b in db.bids on u.UserID equals b.UserId
where b.DocID == id
join p in db.Products
on b.BidID equals p.BidId
join x in db.Others on b.UserId equals x.UserId into others
from o in others.DefaultIfEmpty()
Select ???

话又说回来,如果您的实体之间有适当的关联,您可能能够避免所有连接,并通过直接导航对象图来投影到所需的形状。

关于c# - 林奇 : Error using multiple from and Join,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7941771/

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