【发布时间】:2015-08-28 19:19:57
【问题描述】:
我正在使用 xElement 查询将 xml 文档中的数据提取到结构中。我想将存储的数据限制为仅在某些字段包含特定字符串的一部分时。
此代码有效,但字符串必须完全匹配。
var data = from query in xmlDocFromPage.Descendants("DIRECTORY")
where (string)query.Element("lastNAME") == "Smith"
select new contactDataClass
{
lastName = (string)query.Element("lastNAME"),
firstName = (string)query.Element("firstNAME"),
middleName = (string)query.Element("middleNAME")
};
我正在尝试实现相当于以下 sql 外观的语句。
where (string)query.Element("lastNAME") like "%Smith%"
有可能吗?
【问题讨论】:
标签: c# windows-phone xelement