0
我試圖解析一個mvcSiteMap,我已經得到了大部分的工作,但我的where子句它不正確。它總是返回where子句應該排除的行。Linq到Xml noob問題
nodeTitle = "Bulk Order Request";
XElement xelement2 = XElement.Load(filePath);
var urlDescList1 = (xelement2.Descendants()
// Select node with 'Favorite Social Sites'
.Where(node => (string) node.Attribute("title").Value != nodeTitle)
.SelectMany(node => node.Elements())
.Select(node => new
{
title = node.Attribute("title").Value,
url = node.Attribute("action").Value
})).ToList();
無論where子句是否存在,我都得到相同數量的行返回。 這就像在where子句永遠是真實的,即使輸出lsit的標題元素包含「批量訂單需求」作爲其稱號
我知道我在做什麼Obvioulsy愚蠢的,但我不能看見。
感謝,
Eric-
XML
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-1.0">
<mvcSiteMapNode title="Home" controller="Home" action="Index" isDynamic="true" dynamicParameters="*" >
<mvcSiteMapNode title="Home" controller="RunWebForm" action="DisplayPage/~-Scout_Main-HelloPage.aspx" roles="*" />
<mvcSiteMapNode title="Inbond Call" controller="RunWebForm" action="DisplayPage/~-Scout_HandleCall-StartCall.aspx" roles="*" />
<mvcSiteMapNode title="Reports" controller="NoController" action="NoAction/80" roles="*" >
<mvcSiteMapNode title="Activity By Type" controller="Reports" action="ActivityByType" roles="*" />
<mvcSiteMapNode title="Activity By Agent" controller="Reports" action="ActivityByAgent" roles="*" />
<mvcSiteMapNode title="Activity By Language" controller="Reports" action="ActivityByLang" roles="*" />
<mvcSiteMapNode title="Complaints" controller="Reports" action="ComplaintReport" roles="*" />
<mvcSiteMapNode title="Volume by Date Time" controller="Reports" action="VolumeByDateTime" roles="*" />
<mvcSiteMapNode title="Activity By Gender" controller="Reports" action="CallPersonActivityByGenderReport" roles="*" />
<mvcSiteMapNode title="Prospects by Age" controller="Reports" action="ActivitybyProspectsbyAge" roles="*" />
<mvcSiteMapNode title="Prospects by Ethnicity" controller="Reports" action="ActivitybyEthnicity" roles="*" />
<mvcSiteMapNode title="Prospects by Gender" controller="Reports" action="ActivitybyGender" roles="*" />
<mvcSiteMapNode title="Prospects by Language" controller="Reports" action="ActivitybyLanguage" roles="*" />
<mvcSiteMapNode title="Activity by Referral Source" controller="Reports" action="ActivitybyReferralSource" roles="*" />
</mvcSiteMapNode>
<mvcSiteMapNode title="Fullfillment letter" controller="NoController" action="NoAction/9" roles="*" >
<mvcSiteMapNode title="Bulk Order Request" controller="Reports" action="ActivityByBulkOrderRequest" roles="*" />
<mvcSiteMapNode title="Letter English" controller="Reports" action="LetterEnglish" roles="*" />
<mvcSiteMapNode title="Letter English - General Inquiry" controller="Reports" action="LetterEnglishForGeneralInquiry" roles="*" />
</mvcSiteMapNode>
<mvcSiteMapNode title="Maintenance" description="Maintenance" controller="NoController" action="NoAction/11" roles="4048">
<mvcSiteMapNode controller="RunWebForm" action="DisplayPage/~-Scout_Main-Administration-MaintainScripts.aspx" title="Maintain Call Scripts " description="Maintain Call Scripts" roles="4048"/>
<mvcSiteMapNode controller="RunWebForm" action="DisplayPage/~-Scout_Main-Administration-MediaTypeMaintain.aspx" title="Maintain Media Items " description="Maintain Media Items" roles="4048"/>
<mvcSiteMapNode controller="RunWebForm" action="DisplayPage/~-Scout_Main-Administration-CallMainSource.aspx" title="Maintain Call Main Sources " description="Maintain Call Main Sources" roles="4048"/>
<mvcSiteMapNode controller="RunWebForm" action="DisplayPage/~-Scout_Main-Administration-CallSecondarySource.aspx" title="Maintain Call Secondary Sources " description="Maintain Call Secondary Sources" roles="4048"/>
<mvcSiteMapNode controller="RunWebForm" action="DisplayPage/~-Scout_Main-Administration-CallOtherLanguage.aspx" title="Maintain Additional Languages" description="Maintain Additional Languages" roles="4048"/>
</mvcSiteMapNode>
<mvcSiteMapNode controller="Account" action="Logon" title="Logout" description="Logout and return to the login screen" roles="*" />
</mvcSiteMapNode>
</siteMap>
請格式化你的LINQ查詢的代碼。 – 2009-07-15 22:18:21