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