I have a DataGridView that I want to query using Linq (C # WinForm). I want to "count" lines where certain criteria are met. For example,
variable1 = "count rows where ColumnBoxAge > 3 || < 5" label1.Text = variable1
How can I do this in C # WinForm using Linq?
I don't know if it might work, but you can try this:
dataSet.Tables[0].AsEnumerable().Where(c => c.Field<int>("ageColumn") > 3 || c.Field<int>("ageColumn") < 5).Count();
Edit: where instead of Select.
So, your request is wrong! Try '& &' instead of '||';
dataSet.Tables[0].AsEnumerable().Where(c => c.Field<int>("ageColumn") > 3 && c.Field<int>("ageColumn") < 5).Count();
@yapiskan
... Where instead of. Please select
Many thanks! I appreciate your help.