0

I have a datatable with Multiple Columns. I am trying to extract a row that matches multiple conditions. My code for the same is

   var filtered = Results.AsEnumerable()
.Where(r => r.Field<String>("Suite").Contains(Suite_Name)
       &&   r.Field<String>("Case").Contains(Case_Name)
       &&   r.Field<String>("Name").Contains(Word.Name));

I have opened the data table and there are rows that matches the exact values that are passed as input but still it does not return any values. Is there anything that I am doing wrong ?

Sefe
  • 13,731
  • 5
  • 42
  • 55
  • 3
    Please provide us the value of the "Results" – Ray Krungkaew Dec 15 '17 at 07:33
  • 1
    if you're trying to extract a single row I would omit AsEnumerable and use .FirstOrDefault instead of Where – michal.jakubeczy Dec 15 '17 at 07:37
  • Results table has four columns namely Suite , Case , Name and Result – Sudhir Somasundaram Dec 15 '17 at 07:37
  • Just curious, should the underscore `_` be a dot `.` in the first two input `Suite_Name` and `Case_Name`? Or should the dot be an underscore in the third one `Word.Name`? Wondering why they're different. – Racil Hilan Dec 15 '17 at 07:40
  • @RacilHilan in the third parameter Word is a class and I am just getting its attribute called Name. – Sudhir Somasundaram Dec 15 '17 at 07:42
  • 1
    If you sure that table contains row which fill provided conditions - start investigation by removing conditions and find where rows are filtered out. Another important question - how you check that _but still it does not return any values_? – Fabio Dec 15 '17 at 07:50
  • Use the datatable viewer by putting break point (F11) on statement posted. Run until you get to break point. Then hover on Results and look at down arrow on the viewer. A pop up window will appear with contents of the DataTable. – jdweng Dec 15 '17 at 07:55
  • Are you properly casing the input output text? – Filip Cordas Dec 15 '17 at 10:04
  • Do your cases match? – NetMage Dec 15 '17 at 23:46

0 Answers0