- 0
entity framework Can't figure out how to search by array
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Similar Content
-
- 5 replies
- 980 views
-
- 12 answers
- 11863 views
-
- 2 answers
- 2428 views
-
- 2 answers
- 2199 views
-
- 2 answers
- 4959 views
-
Question
+Red King Subscriber²
I have about a few hours of experience (code first).
I cannot figure out how to get a single element out by its hash:
UserAgent userAgent = db .UserAgents .FirstOrDefault(ua => ua.Hash.SequenceEqual(uaHash));This crashes saying that SequenceEqual is unsupported or some such Linq To Sql jibberish.Of course I can get all the elements out of the DB and then do an unsafe UInt64 binary comparison.
But that is nasty O(n) each time.
I am attempting to store IP addresses and Hashes (for fast lookup) in DB.
[Required] [MaxLength(16)] // 128 - IP6 [MinLength(4)] // 32 - IP4 public byte[] Ip { get; set; }[Required] public byte[] Hash { get; set; }Ofc I can try simply writing old fashioned SQL queries, but that just kills the nice aspect of having a model automatically generated for you via POST, validated, and saved with a few lines of code.Link to comment
https://www.neowin.net/forum/topic/1199889-cant-figure-out-how-to-search-by-array/Share on other sites
6 answers to this question
Recommended Posts