I am trying to Convert this DataTable Select query to Linq. The purpose is to get the values from column lookupValueField
private object[] GetValueFromLookup(MultipleKeyConditionBuilder filter, string lookupValueField, DataTable datatableLookup)
{
object[] result;
DataRow[] rows = datatableLookup.Select(filter.Condition);
result = new object[rows.Count()];
for (int i = 0; i < rows.Count(); i++)
{
result[i] = rows[0][lookupValueField];
}
return result;
}
This is the Linq query I have written so Far. The condition is already defined in the filter. filter contains following type of value 'Project_id = 10'. How can I use this filter in my where clause. currently it is giving an error. 'cannot implicitly convert string to bool'
private object[] GetValueFromLookup(MultipleKeyConditionBuilder filter, string lookupValueField, DataTable datatableLookup)
{
object[] result;
EnumerableRowCollection<DataRow> rows;
//DataRow[] rows;
rows = from myRow in datatableLookup.AsEnumerable()
where filter.Condition
select myRow ;
result = new object[rows.Count()];
for (int i = 0; i < rows.Count(); i++)
{
result[i] = rows; // should give only lookupcolumn
//result[i] = rows[0][lookupValueField];
}
return result;
}
lastly I want to get result in an array of rows and not in EnumerableRowCollection. I want the result as it is in above array. Any help would be useful