LINQPad 应用
https://www.linqpad.net/
使用 LINQPad 调试linq以及lambda表达式
http://www.studyofnet.com/news/1168.html
linq 转化XML , 可以方便地把XML导出为CSV
var path = @"d:\temp\note.xml";
var doc = XDocument.Load(path);
doc.Dump();
var q = from x in doc.Elements()
select new {
name=x.Attribute("name").Value
,to=x.Elements("to").FirstOrDefault().Value
,fromcol=x.Elements("from").FirstOrDefault().Value
,heading=x.Elements("heading").FirstOrDefault().Value
,body=x.Elements("body").FirstOrDefault().Value
};
q.Dump();
linq查询EventLog
string eventLogLocation = @"d:\temp\Application.evtx"; //var query = new EventLogQuery("Application", PathType.LogName, "*[System/Level=2]"); string queryString = "*"; // XPATH Query EventLogQuery eventsQuery = new EventLogQuery(eventLogLocation, PathType.FilePath, queryString); EventLogReader logReader = new EventLogReader(eventsQuery); for (EventRecord eventInstance = logReader.ReadEvent(); null != eventInstance; eventInstance = logReader.ReadEvent()) { //if(eventInstance.FormatDescription().Contains("SuanMing")){ // Display event info Console.WriteLine("-----------------------------------------------------"); Console.WriteLine("TimeCreated: {0}",eventInstance.TimeCreated.ToString()); Console.WriteLine("Event ID: {0}", eventInstance.Id); Console.WriteLine("Publisher: {0}", eventInstance.ProviderName); Console.WriteLine("Description: {0}", eventInstance.FormatDescription()); String eventXml = eventInstance.ToXml(); Console.WriteLine(eventXml); //} }