没有linq让我怎么活

<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.IO;

public partial class Default8:System.Web.UI.Page
{
protected void Page_Load( object sender,EventArgse)
{
vardata
= new List < WordComponents > ();
(
new DirectoryInfo(Server.MapPath( " data " ))).GetFiles( " *.xml " ).ToList().ForEach(file =>
{
XDocumentdoc
= XDocument.Load(file.FullName);
varq
= fromw in doc.Descendants( " entry " )
select
new WordComponents
{
Word
= w.Descendants( " hw " ).FirstOrDefault().Value.Replace( " _ " , "" ).Replace( " ^ " , "" ),
idioms
= (fromi in w.Descendants( " idiom " )
selecti.Element(
" phrase " ).Value).ToList(),
phrases
= (fromp in w.Descendants( " phraserec " )
selectp.Element(
" phrase " ).Value).ToList(),
phrasalverbs
= (frompv in w.Descendants( " phrasal_verb " )
selectpv.Element(
" phrase " ).Value).ToList(),
};
data.AddRange(q.ToList());
}
);

varqu
= fromw in dataorderbyw.runons.Count + w.phrases.Count + w.phrasalverbs.Countdescendingselectw;
qu.Take(
500 ).ToList().ForEach(w => Response.Write( string .Format( " <strong>{0}</strong>contains{4}elements(idiomcount:{1}/phrasecount:{2}/phrasalverbcount:{3})<br/> " ,w.Word,w.idioms.Count,w.phrases.Count,w.phrasalverbs.Count,w.idioms.Count + w.phrases.Count + w.phrasalverbs.Count)));
}

public class WordComponents
{
public string Word{ get ; set ;}
public List < string > runons{ get ; set ;}
public List < string > idioms{ get ; set ;}
public List < string > phrases{ get ; set ;}
public List < string > phrasalverbs{ get ; set ;}

public WordComponents()
{
runons
= new List < string > ();
idioms
= new List < string > ();
phrases
= new List < string > ();
phrasalverbs
= new List < string > ();
}
}
}


<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml.Linq;
using System.IO;
using System.Data;

public partial class Default7:System.Web.UI.Page
{
public class stat
{
public string Name{ get ; set ;}
public string Value{ get ; set ;}
}

protected void Page_Load( object sender,EventArgse)
{
vardata
= new List < stat > ();
(
new DirectoryInfo(Server.MapPath( " data " ))).GetFiles( " *.xml " ).ToList().ForEach(file =>
{
XDocumentdoc
= XDocument.Load(file.FullName);
data.AddRange((fromw
in doc.Descendants( " entry " ).Descendants()
where w.Attribute( " url " ) != null
select
new stat
{
Value
= w.Attribute( " url " ).Value,
Name
= w.Name.LocalName
}).ToList());
});

(fromd
in data
groupdbyd.Nameintog
select
new {g.Key,Num = g.Count()}).ToList().ForEach(
a
=> Response.WriteLine( string .Format( " {0}:{1} " ,a.Key,a.Num)));

}
}

public static class ext
{
public static void WriteLine( this HttpResponseresponse, object o)
{
response.Write(o.ToString()
+ " <br/> " );
}
}

你可能感兴趣的:(Web,xml,UI,ext,LINQ)