I am inserting data, using EF, which contains a SHA512 Hash. I am then looking up the same data like this, but no results are returned:
var searchHash = requestToFind.GetSelfSha512Hash();
var foundRequest = _complianceContext.ScoreResults
.Where(sr => sr.SearchHash == searchHash);
Both sr.SearchHash
and searchHash
are byte[]
.
If I take out the Where
clause, I do get 1 result. Any ideas why this may be?
The equality operator does not work like you expect for byte arrays. Try SequenceEqual.
var foundRequest = _complianceContext.ScoreResults
.Where(sr => sr.SequenceEqual(searchHash));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With