DataTable AsEnumerable 的使用

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

 

posted @ 2014-02-24 14:52  yellowshorts  阅读(9245)  评论(0编辑  收藏  举报