我有这个包含实体列表的 XML:
<?xml version="1.0" encoding="utf-8" ?>
<Connections>
<Connection>
<ConnectionName>connName</ConnectionName>
<InterfaceName>Account Lookup</InterfaceName>
<RequestFolder>C:\Documents and Settings\user\Desktop\Requests</RequestFolder>
<ResponseFolder>C:\Documents and Settings\user\Desktop\Responses</ResponseFolder>
</Connection>
</Connections>
我正在尝试根据其名称检索其中一个并从中构建一个对象。
var results = (from i in this.Elements("Connection")
where i.Element("ConnectionName").ToString() == stubConnectionName
select new {
interfaceName = ((string)i.Element("InterfaceName").Value),
requestFolder = ((string)i.Element("RequestFolder").Value),
responseFolder = ((string)i.Element("ResponseFolder").Value),
}).Single();
return new StubConnection(stubConnectionName, results.interfaceName, results.requestFolder, results.responseFolder);
问题是结果返回为空。我的查询有什么问题?