我正在使用xml和linq。
我有两个xml文件都包含“ID”和“LANGUAGE”
我想根据两个文件中ID和LANGUAGE相等的位置进行连接 我有这样的事情:
var data=
from details in h_details.Descendants("ROW")
join inst in instance.XPathSelectElements("//Row")
on details.Element("ID").Value
equals inst.XPathSelectElement("Field[@Name=\'h_id\']").Value
and on details.Element("LANGUAGE").Value
equals inst.XPathSelectElement("Field[@Name=\'h_lang\']").Value
basically the "and" statement wont work, so how do i join based on 2 conditions?
答案 0 :(得分:2)
救援的匿名类型。
var data=
from details in h_details.Descendants("ROW")
join inst in instance.XPathSelectElements("//Row")
on new {
x = details.Element("ID").Value,
y = details.Element("LANGUAGE").Value
} equals new {
x = inst.XPathSelectElement("Field[@Name=\'h_id\']").Value,
y = inst.XPathSelectElement("Field[@Name=\'h_lang\']").Value
}
select ... ;
答案 1 :(得分:0)
尝试联合获取两个列表并加入它们