任何人都可以帮我解决这个SQL查询如何在LINQ中编写
SELECT FGA_Vin.vin,
FROM FGA_Vin INNER JOIN Info_Global
ON FGA_Vin.Vin='XXXXXXXXXX' AND
FGA_Vin.NHard=dbo.Info_Global.NHard AND
Info_Global.NVerHard like '%'+FGA_Vin.NVerHard and
Info_Global.NVerSoft like '%'+FGA_Vin.NVerSoft
inner join Info_Associa
on Info_Associa.KeyJoined = Info_Global.NomeFile
我试过了
var reportdata = from Vin in FGA_Vin
join Global in Info_Globals
on Vin.NHard equals Global.NHard
&& on Global.NVerHard equals Vin.NVerHard
select new XElement("flash",
new XElement("Vin", Vin.Vin),
new XElement("ModelType", Global.Model_Type)
);
但是当我添加"&&在Global.NVerHard上等于Vin.NVerHard"然后它都是红色的。
如果&&和&&没有回复
由于
答案 0 :(得分:0)
也许是这样的:
var result=
(
from v in db.FGA_Vin
from i in db.Info_Global
.Where(w=>
w.NHard==v.NHard &&
w.NVerHard.Contains(v.NVerHard) &&
w.NVerSoft.Contains(v.NVerSoft)
)
join ia in db.Info_Associa
on i.NomeFile equals ia.KeyJoined
where v.Vin=="XXXXXXXXXX"
select v.vin
).ToList();
其中db
是linq数据上下文
答案 1 :(得分:0)
var reportdata =
(from Vin in FGA_Vin
join Global in Info_Globals on new {Vin.NHard, Vin.NVerHard } equals {Global.NHard, Global.NVerHard }
join Info_Associa on Info_Global.NomeFile equals Info_Associa.KeyJoined
where Info_Global.NVerHard.Contains(FGA_Vin.NVerHard)
where Info_Global.NVerSoft.Contains(FGA_Vin.NVerSoft)
select new XElement("flash",
new XElement("Vin", Vin.Vin),
new XElement("ModelType", Global.Model_Type)
);
答案 2 :(得分:0)
尝试这样的事情: -
var result =
(
db.FGA_Vin.SelectMany(v => db.Info_Global
.Where(w =>
w.NHard == v.NHard &&
w.NVerHard.Contains(v.NVerHard) &&
w.NVerSoft.Contains(v.NVerSoft)
), (v, i) => new {v, i})
.Join(db.Info_Associa, @t => i.NomeFile, ia => ia.KeyJoined, (@t, ia) => new {@t, ia})
.Where(@t => v.Vin == "XXXXXXXXXX")
.Select(@t => v.vin)
).ToList();