随笔分类 -  Linq

LinQ To Object 基本用法
摘要:inq的基本语法:varresult=fromitemincontainerselectitem;linq获取数据子集:varresult=fromitemincontainerwherebooleanexpressionselectitem;Select用法:var selectedItems = from item in items where item.ParentID == parentID orderby item.SortIndex descending ,item.Nameascending select ite... 阅读全文
posted @ 2012-11-10 00:20 terry.zh 阅读(17478) 评论(5) 推荐(10)
SelectMany 和 Select的区别
摘要:如果我们看这两个扩展函数的定义很容易明白——Select是把要遍历的集合IEnumerable<T>逐一遍历,每次返回一个T,合并之后直接返回一个IEnumerable<T>,而SelectMany则把原有的集合IEnumerable<T>每个元素遍历一遍,每次返回一个IEnumerable<T>,把这些IEnumerable<T>的“T”合并之后整体返回一个IEnumerable<T>。因此我们可以说一般情况下SelectMany用于返回一个IEnumerable<IEnumerable<T>>的 阅读全文
posted @ 2012-11-04 22:15 terry.zh 阅读(2415) 评论(0) 推荐(0)