LinQ Attempt
2008-05-07 10:37 俺是老Z 阅读(246) 评论(0) 收藏 举报
LinQ to XML:
private void ImportXMLToSQL(string xmlFileLocation)
{
var doc = XDocument.Load(xmlFileLocation);

var q = from p in doc.Elements("AzAdminManager").Elements("AzApplication") select p;
foreach (var e in q)
{
this.txtProcess.Text += e.Attribute("Name").Value + "\r\n";
//Console.WriteLine(e.Element("name").Value);
}

}
LinQ to SQL:
private void GetAzManApplicationLINQToSQLData()
{
var azApps = from azapp in azDBdc.AzMan_AzApplications select azapp;
//{
// azAppGUID = azapp.ObjectGuid,
// azAppDescription = azapp.Description,
// azAppName = azapp.Name,
// azAppApplicationVersion = azapp.ApplicationVersion
//};

foreach (var e in azApps)
{
this.txtProcess.Text += e.Name + "\r\n";
this.txtProcess.Text += e.ApplicationVersion + "\r\n";
this.txtProcess.Text += e.Description + "\r\n";
this.txtProcess.Text += e.ObjectGuid + "\r\n";
}

}
Lambda: (参数列表) => 表达式或者语句块
var list = new [] { "aa", "bb", "ac" };

var result = Array.FindAll(list, s => (s.IndexOf("a") > -1));

foreach (var v in result)

Console.WriteLine(v);
private void ImportXMLToSQL(string xmlFileLocation)
{
var doc = XDocument.Load(xmlFileLocation);
var q = from p in doc.Elements("AzAdminManager").Elements("AzApplication") select p;
foreach (var e in q)
{
this.txtProcess.Text += e.Attribute("Name").Value + "\r\n";
//Console.WriteLine(e.Element("name").Value);
}
}LinQ to SQL:
private void GetAzManApplicationLINQToSQLData()
{
var azApps = from azapp in azDBdc.AzMan_AzApplications select azapp;
//{
// azAppGUID = azapp.ObjectGuid,
// azAppDescription = azapp.Description,
// azAppName = azapp.Name,
// azAppApplicationVersion = azapp.ApplicationVersion
//};
foreach (var e in azApps)
{
this.txtProcess.Text += e.Name + "\r\n";
this.txtProcess.Text += e.ApplicationVersion + "\r\n";
this.txtProcess.Text += e.Description + "\r\n";
this.txtProcess.Text += e.ObjectGuid + "\r\n";
}
}Lambda: (参数列表) => 表达式或者语句块
var list = new [] { "aa", "bb", "ac" };
var result = Array.FindAll(list, s => (s.IndexOf("a") > -1));
foreach (var v in result)
Console.WriteLine(v);

浙公网安备 33010602011771号