I have written a LINQ Query to perform a simple where query against a database. However, I noticed there are two methods of doing this, the first I picked up from a book and the second is what I'm seeing mainly online:
First
IQueryable<WebApi.Models.User>? users = db.Users?
.Where(user => user.EmailAddress.Equals(loginRequest.EmailAddress) && user.Password.Equals(loginRequest.Password));
Second
WebApi.Models.User user = (from u in db.Users
where u.EmailAddress.Equals(loginRequest.EmailAddress) && u.Password.Equals(loginRequest.Password)
select u).SingleOrDefault();
The first uses the IQueryable interface while the second does not. What is the difference between the two and does IQueryable provide any advantages over the local variable method?