ahmed elbarbary

ahmed elbarbary

  • 638
  • 1.6k
  • 281.7k

How to check count files inside Res is equal 1 or not ?

Jun 7 2020 8:05 PM
I work on c# app I face Issue I need to check count of files inside result equal 1 or not ?
 
when I use count res.count count not display AS Int license .
 
so by any way I need to check on result variable if returned one file or bigger than 1
 
so How to do that Please ?
  1. static void Main(string[] args) {  
  2.  DataTable dataTable = GetData();  
  3.  var res = from row in dataTable.AsEnumerable()  
  4.  group row by row["Files"] into g  
  5.  select g;  
  6.  if (res.count == 1) {} else {}  
  7. }  
  8. public static DataTable GetData() {  
  9.  DataTable dataTable = new DataTable();  
  10.  dataTable.Columns.Add("PartId"typeof(int));  
  11.  dataTable.Columns.Add("Company"typeof(string));  
  12.  dataTable.Columns.Add("Files"typeof(string));  
  13.  dataTable.Columns.Add("Tab"typeof(string));  
  14.  dataTable.Columns.Add("Module"typeof(int));  
  15.   
  16.  dataTable.Rows.Add(1222, "micro""Abc""source", 1);  
  17.  dataTable.Rows.Add(1321, "silicon""Abc""Types", 3);  
  18.  dataTable.Rows.Add(1444, "cd2""AutoD""Rev", 10);  
  19.  dataTable.Rows.Add(1321, "cd3""AutoD""source", 11);  
  20.  dataTable.Rows.Add(1541, "mtvscro""AutoD""Rev", 12);  
  21.  dataTable.Rows.Add(9811, "tvs2""Mog""Dal", 6);  
  22.  dataTable.Rows.Add(1901, "tvs3""Mog""Mondo", 6);  
  23.  dataTable.Rows.Add(2111, "toyo""Mog""Pingo", 7);  
  24.  return dataTable;  
  25. }  

Answers (1)