gpt4 book ai didi

sql-server - 在 LINQ 中选择具有奇怪值 @p__linq__0

转载 作者:行者123 更新时间:2023-12-02 13:02:31 25 4
gpt4 key购买 nike

我在 LINQ 中有这个选择

 public List<EquipamentoNoDiscovery> GetEquipamentosNoDiscovery(int imID)

var lista = (from ma in ctx.macaddress
join m in ctx.mac on
ma.address_mac equals m.mac_id into g1
from m in g1.DefaultIfEmpty()

join ml in ctx.mac_link on
m.mac_id equals ml.mac_id into g2
from ml in g2.DefaultIfEmpty()

join im in ctx.immobile on
ml.link_id equals im.immobile_id into g3
from im in g3.DefaultIfEmpty()

join en in ctx.enterprise on
im.enterprise_id equals en.enterprise_id into g4
from en in g4.DefaultIfEmpty()

join pl in ctx.port_link on
ma.address_id equals pl.address_id into g5
from pl in g5.DefaultIfEmpty()

join p in ctx.port on
new { pl.sw_id, pl.port_id } equals new { p.sw_id, p.port_id }

join s in ctx.switch_lan on
pl.sw_id equals s.sw_id into g6
from s in g6.DefaultIfEmpty()
where pl.address_id == imID
select new
{
Regiao = en.enterprise_u_name,
Predio = im.immobile_u_name,
Equipamento = m.host,
TipoPlaca = m.mac_type,
Mac = ma.address_mac,
Ip_ma = ma.address_ip,
Ip_m = m.ip_address,
Comunidade = s.sw_community,
IpSwitch = s.sw_ip,
PortaIndex = p.port_index,
PortaNome = p.port_name
});

ObjectQuery oQuery = (ObjectQuery)lista;
string cmdSQL = oQuery.ToTraceString();

当我使用命令 oQuery.ToTraceString() 时,我可以看到“where pl.address_id == imID”变成了“WHERE [Extent6].[address_id] = @p_linq_0 ”。然后我的选择总是返回空,如果在 SQL 命令中我将值 @p_linq_0 更改为数字,它工作正常。请问有什么建议吗?谢谢!

最佳答案

这只是一个来自 where 子句的查询参数。

where pl.address_id == imID

您的日志还应该显示为该参数传递的值,该值应该是 imID 的值。检查该值 - 它可能不是您期望的值。

关于sql-server - 在 LINQ 中选择具有奇怪值 @p__linq__0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13685127/

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