Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
public class ApplicationUser : IdentityUser
{
public Boolean status { get; set; }
}
var result1 = _context.Users.Where(x => x.Email == model.Email && x.status == true).FirstOrDefaultAsync();
does not work. It is not related to signin or login. 


What I have tried:

var result1 = _context.Users.Where(x => x.Email == model.Email && x.status == true).FirstOrDefaultAsync();

is not executed and remains null
Posted
Updated 25-Jul-18 4:36am
Comments
ZurdoDev 24-Jul-18 7:57am    
Debug it and make sure you know what is in model.Email. Otherwise, I'm not sure what you want us to do. We can't see anything else that you have nor can we run your code.

1 solution

FirstOrDefaultAsync returns a Task. To get the result, you need to await that task, which means your method needs to be async.
C#
var result1 = await _context.Users.Where(...).FirstOrDefaultAsync();

Asynchronous Programming with async and await (C#) | Microsoft Docs[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900