Mark Tabor

Mark Tabor

  • 587
  • 2k
  • 457.1k

Why Context Return Null in entity framework

May 1 2019 3:56 AM
why validate return null although i have it
  1. public Registration ValidateUser(string userName, string passWord)  
  2. {  
  3. try  
  4. {  
  5. using (var _context = new DatabaseContext())  
  6. {  
  7. var validate = (from user in _context.Registration  
  8. where user.Username == userName && user.Password == passWord  
  9. select user).SingleOrDefault();  
  10. var users=_context.Registration;  
  11. return validate;  
  12. }  
  13. }  
  14. catch (Exception)  
  15. {  
  16. throw;  
  17. }  
  18. }  
  1. public DbSet<Registration> Registration { getset; }
and in db i have Registration table with records

Answers (3)