随笔分类 - Linq
摘要:代码:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Data;using System.Reflection;namespace TestConsole{ public class Program { public static void Main(string[] args) { var classify_list = new List { ...
阅读全文
摘要:let: String[] strs = { "A penny saved is a penny earned.", "The early bird catches the worm.", "The pen is mightier than the sword." }; var result = from s in strs //s是数组strs中的一个元素 let word = s.Split(' ') //word是s句子中的单词数组 ...
阅读全文
摘要:还是上一份的代码例子: public class Person { public int ID { get; set; } public string Name { get; set; } public int Age { get; set; } } public class Dog { public int ID { get; set; } public string Name { get; set; } public int PersonID { get; set; ...
阅读全文
摘要:代码: public class Person { public int ID { get; set; } public string Name { get; set; } public int Age { get; set; } } public class Dog { public int ID { get; set; } public string Name { get; set; } public int PersonID { get; set; } }...
阅读全文
摘要:延迟加载,亦称延迟实例化,延迟初始化等,主要表达的思想是,把对象的创建将会延迟到使用时创建,而不是在对象实例化时创建对象,即用时才加载。这种方式有助于提高于应用程序的性能,避免浪费计算,节省内存的使用等。针对于这种做法,似乎称之为即用即创建更为合适些。例如:一个文章实体类Article,一个文章分类实体类Category,通过Article获取相对应的Category方法1:在获取Article实体类时,将相对应的Category实体类塞给Article方法2:要调用Category时,通过Article从数据库中获取方法3:在Category属性的get访问器中实现读取数据库获取文章分类的代
阅读全文