标签:集中 lin 直接 join 一个 选择 substr bst string
string[] names = { "Alonso", "zheng", "Smith", "Jones", "Smythe", "Small", "Ruiz", "Hsieh", "Jorgenson", "Ilyich", "Singh", "Samba", "Fatimah" }; var queryResults = from n in names where n.StartsWith("S") select n; foreach (var item in queryResults) { Console.WriteLine(item); } Console.ReadKey(); }
string[] names = { "Alonso", "zheng", "Smith", "Jones", "Smythe", "Small", "Ruiz", "Hsieh", "Jorgenson", "Ilyich", "Singh", "Samba", "Fatimah" }; var queryResults = names.Where(n => n.StartsWith("s")); //以s开头 foreach (var item in queryResults) { Console.WriteLine(item); } Console.ReadKey(); }
orderby n
orderby n descending
orderby n.Substring(n.Length - 1);
names.orderby(n => n);
Count()//计数 Min(), Max(), Average() Sum();
var queryResults = customers.Select(c => c.Region).Distinct();
var queryResults = from c in customers orderby c.Region,c.COuntry,c.City select new {c.ID,c.Region}
var queryResults = customers.OrderBy(c => c.Region) .ThenBy(c => c.Country) .ThenBy(c => c.City) .select(c => new{c.ID,c.Region,c.Country})
foreach(var item in queryResults.Take(5)){ }
var queryResults = from c in customers join o in orders on c.ID equals o.ID select new{c.ID,c.City,}
XDocument xdoc = new XDocument( new XElement("customers", new XElement("customers", new XAttribute("ID", "A"), new XAttribute("City", "New York"), new XAttribute("Region", "North America"), new XElement("order", new XAttribute("Item", "Tire") ) ), new XElement("customer") ) );
XDocument xdoc = XDocument.Parse(@"<customers>.....</customers>")
标签:集中 lin 直接 join 一个 选择 substr bst string
原文地址:http://www.cnblogs.com/sjyzz/p/7793333.html