0

I have the following query, works great with an email of my own or many peoples to be exact but a few of them just don't get found.

Query:

var result = lic.Where(x => (string)x["Email"].ToString().ToLower() == email.ToLower()).FirstOrDefault();

I took the liberty of trying a much simpler expression and still the same result:

var result = lic.Where(x => (string)x["Badge"].ToString() == "10419").First();

I am using a List Collection in the Sharepoint.dll

I have confirmed that there IS a record in this list with this information. for a 100% fact, the data is there.

If I plug in my email, this query pulls my record with no issues. But if I put in a certain employee's email, this function returns a null reference like there was no record found in my List Collection.

I am at a complete loss here.

Thanks

-Garen

Garen
  • 69
  • 4
  • 1
    If you use `string.Equals((string)x["Email"), email, StringComparison.OrdinalIgnoreCase)`, does it make a difference? – ProgrammingLlama Jul 08 '21 at 00:02
  • Why did you not use x.Email rather than x["Email"] ? – Ismail Jul 08 '21 at 00:05
  • @Llama You sir are a genius! Thank you! Now that you solved my misery for the last who knows how long. What was wrong with my query? Besides your looks so much cleaner and easier to understand. – Garen Jul 08 '21 at 00:10
  • 1
    See also: [String comparison - strA.ToLower()==strB.ToLower() or strA.Equals(strB,StringComparisonType)?](https://stackoverflow.com/q/1660192/8967612) – 41686d6564 stands w. Palestine Jul 08 '21 at 00:19

0 Answers0