var p = DataTable.AsEnumerable().Where(t => t.Field<int>("ChannelID") == int.Parse(code)).Select(d => d);
if (p != null && p.Count() > )
{
return p.Select(c => c.Field<string>("name")).First();
}
else
{
return "";
}

DataTable AsEnumerable 的使用的更多相关文章

  1. c# Lamdba及DataTable AsEnumerable()的使用

    Lamdba是延迟执行的,实际上什么都没有发生,当真正使用对象的时候(例如调用:First, Single, ToList-.的时候)才执行. 1.Where var var_dtTable = dt ...

  2. DataTable无法使用AsEnumerable ()的解决办法

    本人定义了DataSet后将表1赋给datatable,在写linq时调用datatable.asenumerable(),但报datatable不包含asenumerable的定义,求高手指点.Sy ...

  3. DataTable与DTO对象的简易转换类

    在web开发过程中,有时候为了数据传输的方便,比如:后台需要更新前端的ViewModel,此时我们定义一个与前端ViewModel结构一样的DTO对象,从数据层获取数据后,将数据封装成DTO然后序列化 ...

  4. c# datatable list 相互转换

    /*Converts List To DataTable*/ public static DataTable ToDataTable<TSource>(IList<TSource&g ...

  5. C# DataTable怎么合计字段

    DataTable dt = new DataTable(); var age=dt.Compute("avg(age)",""); var height =d ...

  6. Conversion Between DataTable and List in C#

    1.List to DataTable public static DataTable ToDataTable<TSource>(this IList<TSource> dat ...

  7. DataTable某一列转换为分隔字符串

    //把DataTable的某一列转化为逗号分隔字符串 private static string DataTableColumnSplit(DataTable dataTable,string str ...

  8. csharp:Conversion Between DataTable and List

    /// <summary> /// http://www.codeproject.com/Tips/784090/Conversion-Between-DataTable-and-List ...

  9. 简洁的导出 datatable到excel,不用组件

    简洁的导出 datatable到excel var lines = new List<string>(); string[] columnNames = dataTable.Columns ...

随机推荐

  1. Qt学习(四)—实例涂鸦画板mspaint

    一.Qt图形绘制 自己在Qt开源社区在自学yafeilinux前辈的<Qt快速入门系列教程>中的图形篇,结合所学的知识,可以做一个涂鸦板实例 二.实现涂鸦板 1.新建工程mspaint, ...

  2. MIT-scheme安装

    下载地址: http://www.gnu.org/software/mit-scheme/ 下载windows版本,安装. The MIT-Scheme can be installed by jus ...

  3. View not attached to window manager crash 的解决办法

    View not attached to window manager crash 的解决办法 转自:http://stackoverflow.com/questions/22924825/view- ...

  4. HDU 5775 Bubble Sort(线段树)(2016 Multi-University Training Contest 4 1012)

    原址地址:http://ibupu.link/?id=31 Problem Description P is a permutation of the integers from 1 to N(ind ...

  5. 使用Canvas实现动画效果 | DKlogs -- 设计 | 生活

    使用Canvas实现动画效果 | DKlogs -- 设计 | 生活 使用Canvas实现动画效果

  6. No enclosing instance of type Outer is accessible. Must qualify the allocation with an enclosing instance of type Outer (e.g. x.new A() where x is an instance of Outer)

    之前看内部类的时候没发现这个问题,今天写代码的时候遇到,写个最简单的例子: 下面这一段代码 红色的部分就是编译报错: No enclosing instance of type Outer is ac ...

  7. bash及其特性(笔记)

    bash及其特性:shell: 外壳GUI:Gnome, KDE, XfceCLI: sh, csh, ksh, bash, tcsh, zsh root, student程序:进程 进程:在每个进程 ...

  8. hdu 5465 Clarke and puzzle(前缀和,异或,nim博弈)

    Problem Description Clarke is a patient with multiple personality disorder. One day, Clarke split in ...

  9. hdu 4750 Count The Pairs(并查集+二分)

    Problem Description With the 60th anniversary celebration of Nanjing University of Science and Techn ...

  10. UILabel Text 加下划线

    .h文件 #import <Foundation/Foundation.h> @interface CustomLabel : UILabel { BOOL _isEnabled; } @ ...