03 2012 档案

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 阅读(222) 评论(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 阅读(235) 评论(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 阅读(215) 评论(0) 推荐(0)

在VS中用正则表达式查找或替换
摘要:在VS中用正则表达式查找或替换正则表达式是查找和替换文本模式的简洁和灵活的表示法。Visual Studio 中使用的正则表达式是 Visual C++ 6.0 中使用的、具有简化语法的表达式的超集。在“查找”、“在文件中查找”或“在文件中替换”对话框中,可使用下列正则表达式来改进和扩展搜索。注意:在将下列任何表达式用作搜索条件的一部分之前,必须在“查找”、“在文件中查找”和“在文件中替换”对话框中选择“使用”复选框,并在下拉框选中正则表达式。可使用下列表达式匹配搜索字符串中的字符或数字:表达式语法说明任一字符.匹配除换行符外的任何一个字符。最多 0 项或更多*匹配前面表达式的 0 个或更多搜 阅读全文

posted @ 2012-03-25 21:15 Sanic 阅读(1274) 评论(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 阅读(270) 评论(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 阅读(216) 评论(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 阅读(259) 评论(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 阅读(184) 评论(0) 推荐(0)

cross apply 和 outer apply
摘要:APPLY的执行过程:它先逻辑计算左表表达式,然后把右表达式应用到左表表达式的每一行。cross tb表都存在姓名的情况下才出现,outer tb外表存在的都显示。 create table #T(姓名 varchar(10))insert into #T values('张三')insert into #T values('李四')insert into #T values(NULL )crea... 阅读全文

posted @ 2012-03-02 23:48 Sanic 阅读(189) 评论(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)

重视Linq技术_2
摘要://Deferred Execution//1、Introductionvar numbers = new List<int>();numbers.Add (1); //10IEnumerable<int> query = numbers.Select (n => n * 10);// Build querynumbers.Add (2); //20 // Sneak in a... 阅读全文

posted @ 2012-03-01 21:45 Sanic 阅读(212) 评论(0) 推荐(0)

导航