C
C#3w ago
Dennis

Cant query the data with specified uid

I got a problem, I am using aps.net 6.0 with ef and dbcontext, I tried to query the uid with 16 char string, however, its not working: I set dbcontext and its working and connected, its string queryuid(uid) { Dbconnection dbcon = dbContext.dbconnection.firstOrDefault(e=>e.Uid == uid); which dbcon always return null, however there are 3 records in database with uid I wanna find, the uid is 16 char string and when I change as: int count = dbContext.dbconnection.Count(e=>e.Uid == uid); its return the int of 2, which is correct, I even tried: dbContext.dbconnection.Where(e=>e.Uid == uid).first(); dbContext.dbconnection.Where(e=>e.Uid == uid).firstOrDefualt(); It's alwasy return null. Can I know whats wrong?
3 Replies
Angius
Angius3w ago
Well, there's no item with the specified Uid Check what uid is, and manually see if it exists in the database Also, what is dbconnection here? A DbSet<DbConnection>?
Dennis
DennisOP3w ago
uid is existed in db
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server