gpt4 book ai didi

c# - LinQ Error linq联合类型推断调用失败 'join'错误

转载 作者:太空宇宙 更新时间:2023-11-03 20:17:03 24 4
gpt4 key购买 nike

我是 Entity Framework 的新手,我正尝试在两个实体上使用 join 子句,如下所示。

var alertlist = from elogAlert  in yangkeeDBEntity.Yang_Kee_Logistics_Pte_Ltd_ELog_Tablet_Alert
where elogAlert.No_ != null
join elogAlertDetail in yangkeeDBEntity. Yang_Kee_Logistics_Pte_Ltd_ELog_Tablet_Alert_Details
on elogAlert.No_ == elogAlertDetail.AlertID



where elogalertdetail.employee_id == driverid
select new
{
elogalertdetail.employee_id,
elogalertdetail.alert_id,
elogalertdetail.no_,
elogalertdetail.status,
elogalertdetail.created_by,
elogalertdetail.date_created,



};

你好,从上面的代码我得到了两个错误

'Error  1   The name 'elogAlertDetail' is not in scope on the left side of 'equals'.  Consider swapping the expressions on either side of 'equals'.' and 'linq joint type inference failed to call 'join' error  '

目前这两个表没有任何数据。如果有人能帮助我解决这种情况,我会很高兴

最佳答案

在加入 Linq 时不能使用 ==。您需要使用 equals

请注意,它不是 method .Equals(..)keyword

from elogAlert  in yangkeeDBEntity.Yang_Kee_Logistics_Pte_Ltd_ELog_Tablet_Alert
join elogAlertDetail in yangkeeDBEntity.Yang_Kee_Logistics_Pte_Ltd_ELog_Tablet_Alert_Details

on elogAlert.No_ equals elogAlertDetail.AlertID //this line has equals instead of ==

where elogAlert.No_ != null
where elogalertdetail.employee_id == driverid
select new
{
elogalertdetail.employee_id,
elogalertdetail.alert_id,
elogalertdetail.no_,
elogalertdetail.status,
elogalertdetail.created_by,
elogalertdetail.date_created,
};

查看documentaion在 Linq 上加入

关于c# - LinQ Error linq联合类型推断调用失败 'join'错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16075281/

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