Posts o[linq] Query a datatable with linq
Post
Cancel

o[linq] Query a datatable with linq

1
2
3
4
5
6
7
8
9
10
11
12
DataTable tbl_N = conn.GetDATATABLE("select * from tbl where convert (varchar(10),addedDate,120)= '" + DateTime.Today.ToString("yyyy-MM-dd") + "' and thefield ='N'");
var tbl = tbl_N.AsEnumerable().
Where(row => row.Field<string>("fieldA") != null && row.Field<string>("fieldA") == "soccer" && string.IsNullOrEmpty(row.Field<string>("fieldB"))).ToList();

            foreach (DataRow item in tbl_N_Phrama_Count)
       {
       not_proceed+=item["field88"] + ", ";
       }

//plain count
int tbl_Count= tbl_N.AsEnumerable().
Count(row => row.Field<string>("fieldA") != null && row.Field<string>("fieldA") == "soccer" && string.IsNullOrEmpty(row.Field<string>("fieldB")));

origin - http://www.pipiscrew.com/?p=5914 linq-query-a-datatable-with-linq

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags