Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search in a List<DataRow>?

I have a List which I create from a DataTabe which only has one column in it. Lets say the column is called MyColumn. Each element in the list is an object array containing my columns, in this case, only one (MyColumn). Whats the most elegant way to check if that object array contains a certain value?

like image 252
grady Avatar asked Jun 15 '10 08:06

grady


1 Answers

var searchValue = SOME_VALUE;
var result = list.Where(row => row["MyColumn"].Equals(searchValue)); // returns collection of DataRows containing needed value
var resultBool = list.Any(row => row["MyColumn"].Equals(searchValue)); // checks, if any DataRows containing needed value exists
like image 53
VMAtm Avatar answered Sep 27 '22 01:09

VMAtm