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. Blog透视镜

    Blog透视镜,提供了Blog代码示例,文章和教程,可以帮助你建置博客. 网站名称:Blog透视镜 网站地址:http://blog.openyu.org

  2. 查看oracle中的中文所占字节数

    select userenv('language') from dual 显示:SIMPLIFIED CHINESE_CHINA.ZHS16GBK 表示一个汉字占用两个字节. 显示:SIMPLIFIE ...

  3. Android Studio 调试过程中快捷查看断点处变量值(Ctrl+Shift+I无效)?

    当你在做Keymap到Eclipse后,在debug过程中,在Eclipse中我们很喜欢用Ctrl+Shift+I去查看一个运算或者调用的结果,这样用起来很方便.但是keymap到Eclipse后,你 ...

  4. bzoj1649 [Usaco2006 Dec]Cow Roller Coaster

    Description The cows are building a roller coaster! They want your help to design as fun a roller co ...

  5. Seletion Sort

    referrence: GeeksforGeeks The selection sort algorithm sorts an array by repeatedly finding the mini ...

  6. Binary Tree Level Order Traversal 解答

    Question Given a binary tree, return the level order traversal of its nodes' values. (ie, from left ...

  7. 【LeetCode练习题】Pow(x, n)

    Pow(x, n) Implement pow(x, n). 计算x的n次方. 解题思路: 考虑到n的值会很大,而且可为正可为负可为0,所以掉渣天的方法就是用递归了. 对了,这题也在<剑指off ...

  8. 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 ...

  9. (转)Java 的swing.GroupLayout布局管理器的使用方法和实例

    摘自http://www.cnblogs.com/lionden/archive/2012/12/11/grouplayout.html (转)Java 的swing.GroupLayout布局管理器 ...

  10. iOS SDK原生JSON解析

    - (IBAction)touchReadButton:(id)sender { NSData *jsonData = [[NSData alloc] initWithContentsOfFile:J ...