1
Answer

LINQ IEnumerable Datarow Select

whizkid gps

whizkid gps

8y
379
1
I've been using following LINQ for querying records from IEnumerable(Datarow). Instead of hardcoding field names in Linq, I want to pass string[] as input parameter and field names needs to be retrieved from string[]. Please assist me on this.
 
 
  1. List<string[]> IDcolls = drResults.Select(q => new[]   
  2.                                 {   
  3.                                      q["empid"].ToString(),                                      
  4.                                      q["empname"].ToString()   
  5.                                 })  
  6.                                 .Skip(mBatch * batchSize)  
  7.                                 .Take(batchSize)  
  8.                                 .ToList(); 
 
  1. string[] IDs = (from q in drResults  
  2.                             select q["empid"].ToString())  
  3.                             .Skip(i * batchSize)  
  4.                             .Take(batchSize)  
  5.                             .ToArray(); 

Answers (1)