whizkid gps

whizkid gps

  • NA
  • 3
  • 5.4k

LINQ IEnumerable Datarow Select

Jul 7 2016 12:33 PM
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)