linq递归】的更多相关文章

Linq递归查找: public IEnumerable<MenuInfo> GetTree(int id, IEnumerable<MenuInfo> lst) { var query = from c in lst where c.parent_menu_id == id select c; return query.Concat(query.SelectMany(t => GetTree(t.menu_id, lst))).ToList(); } 调用如下: int g…
public class Comment { public int Id { get; set; } public int ParentId { get; set; } public string Text { get; set; } public List<Comment> Children { get; set; } } class Program { static void Main() { List<Comment> categories = new List<Com…
http://www.cnblogs.com/terryzh/archive/2012/11/10/2763538.html LinQ To Object 基本用法 inq的基本语法:var result = from item in container select item; linq获取数据子集: var result = from item in container where booleanexpression select item; Select用法: var selectedIt…
Linq 的基本用法: Sort , OrderBy, Skip,Take,Where,Compare,Join,Distinct ,InsertRange 等关键词 Select用法 var selectedItems = from item in items where item.ParentID == parentID orderby item.SortIndex descending ,item.Name ascending select item; 0.1 where : var li…
话不多说,先上实体类,如果你不是codefirst,就把它当成数据表结构. 下面是底层BaseDal获取数据的方法  (如果你没有Base类,直接写在你的DAL层和BLL层) 下面是BaseService的方法 下面方法用于拼接字符串 主体方法-- /// <summary> /// 得到****TreeGrid****的Json ,后台用于管理页面 /// </summary> public string GetAllLeftMenu4TreeGridJson() { Strin…
ALTER VIEW [dbo].[view_TreeLevel] AS WITH cte AS ( SELECT a.ModuleID , a.Module_Name , a.Module_Description , a.Module_FatherID , a.Module_Url , a.Module_Order, 1 Level FROM TT_TreeView a WHERE a.Module_FatherID=0 UNION ALL SELECT b.ModuleID , b.Modu…
private void SetTextReadOnly(Control ctr, bool blReadOnly) { ctr.Controls.Cast<Control>().Select(s => s).ToList<Control>().ForEach(s => { if (s.GetType() == typeof(TextBox)) ((TextBox)s).ReadOnly = blReadOnly; if (s.HasChildren) { SetTex…
using System;using System.Collections.Generic;using System.Linq;using System.Text; namespace MyExample_Hanoi_{    class Program    {        static void Main(string[] args)        {            HanoiCalculator c = new HanoiCalculator();            Cons…
[转载]作者:weixingstudio 采用C#,通过指定一个路径,来递归的遍历所有的子目录以及子目录中的文件,建一个类似资源管理器的目录树 先递归的遍历所有的子目录,如果没有子目录以后,则遍历所有的当前目录下的文件 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using Sys…
.NET面试题系列目录 名言警句 "理解IQueryable的最简单方式就是,把它看作一个查询,在执行的时候,将会生成结果序列." - Jon Skeet LINQ to Object和LINQ to SQL有何区别? LINQ to SQL可以将查询表达式转换为SQL语句,然后在数据库中执行.相比LINQ to Object,则是将查询表达式直接转化为Enumerable的一系列方法,最终在C#内部执行.LINQ to Object的数据源总是实现IEnumerable<T&g…