随笔分类 -  LINQ

Building an XML document
摘要:var doc = new XDocument ( new XDeclaration ("1.0", "utf-16", "yes"), new XElement ("test", "data") );string tempPath = Path.Combine (Path.GetTempPath(), "test.xml");doc.Save (tempPath);File.ReadAllText (tempPath).Dump();Building an XML docu 阅读全文

posted @ 2012-03-27 23:43 Sanic 阅读(219) 评论(0) 推荐(0)

Building an XHTML document
摘要:var styleInstruction = new XProcessingInstruction ( "xml-stylesheet", "href='styles.css' type='text/css'");var docType = new XDocumentType ("html", "-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" 阅读全文

posted @ 2012-03-27 23:39 Sanic 阅读(232) 评论(0) 推荐(0)

LINQ TO XML
摘要:XElement config = XElement.Parse (@"<configuration> <client name='setting1' enabled='true'> <timeout>30</timeout> </client> <client name='setting2' enabled='false'> <timeout>90</timeout> </client></configur 阅读全文

posted @ 2012-03-27 23:21 Sanic 阅读(211) 评论(0) 推荐(0)

重视Linq技术_7
摘要:Projecting - Select//1、Select-Subqueries and Object Hierarchiesstring sampleDirectory = Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments); DirectoryInfo[] dirs = new DirectoryInfo (sampleDirectory).GetDirectories(); var query = from d in dirs where (d.Attributes & FileAttributes. 阅读全文

posted @ 2012-03-05 21:56 Sanic 阅读(268) 评论(0) 推荐(0)

重视Linq技术_6
摘要:Filtering//1、Simple Local Filterstring[] names = { "Tom", "Dick", "Harry", "Mary", "Jay" }; IEnumerable<string> query = names.Where (name => name.EndsWith ("y")); query.Dump ("In lambda syntax"); query = from n in names w 阅读全文

posted @ 2012-03-05 21:00 Sanic 阅读(215) 评论(0) 推荐(0)

重视Linq技术_5
摘要:Building Query Expressions//1、Compiling Expression TreesProducts.DeleteAllOnSubmit (Products.Where (p => p.ID == 999));Products.InsertOnSubmit (new Product { ID = 999, Description = "Test", LastSale = DateTime.Now } );SubmitChanges();Product[] localProducts = Products.ToArray();Expressi 阅读全文

posted @ 2012-03-04 23:47 Sanic 阅读(258) 评论(0) 推荐(0)

重视Linq技术_4
摘要://LINQ to SQL//1、Baisc queryCustomers.Single (c => c.ID == 2) .Dump ("Customer With ID Of 2");//2、AssociationsCustomer cust1 = Customers.OrderBy (c => c.Name).First();foreach (Purchase p In cust1.Purchases)Console.WriteLine (p.Price);//3、 Retrieve the customer who made the lowest val 阅读全文

posted @ 2012-03-04 22:43 Sanic 阅读(183) 评论(0) 推荐(0)

重视Linq技术_3
摘要:Interpreted Queries//1、Simple LINQ to SQL Queryfrom c in Customerswhere c.Name.Contains ("a")orderby c.Name.Lengthselect c.Name.ToUpper()//2、Combining Interpreted and Local Queriesvoid Main(){//This uses a custom 'Pair' extension method, defined below.IEnumerable<string> q = 阅读全文

posted @ 2012-03-01 22:53 Sanic 阅读(160) 评论(0) 推荐(0)

导航