I have a DataTable which I want to query one column at a time to check if it meets the set criteria, for some reason the below code gives correct results for the first column after that the results are incorrect.
private bool BusinessRulesOne(DataTable dt, DataColumn dc)
{
bool isSatisfied = false;
DataRow[] checkColumn = dt.Select(dc.ColumnName + " " + "in (1,2,3,)");
if (checkColumn.Length != 0)
{
isSatisfied = true;
}
return isSatisfied;
}
On this method Im passing the DataTable I'm querying and DataColumn that I'm currently concentrating on. What needs to happen here is that I want to check if the values on this column consists of the values 1,2 and 3. If yes then return true.
private bool BusinessRulesTwo(DataTable dt, DataColumn dc)
{
bool isSatisfied = false;
var checkColumn = dt.Select(dc.ColumnName + " " + " = 1");
if (checkColumn.Count() > 3)
{
isSatisfied = true;
}
return isSatisfied;
}
On the other rule I'm checking if the number of one's (1's) in that column are more than three(3) if yes return true.
Any suggestions are welcome, I'm not clued up with Linq but willing to learn and explore it if it makes life easier.