What is difference between ToList() & AsQueryable()

Mar 15 2018 3:23 AM
please tell me What is difference between ToList() & AsQueryable() ?
 
see the code with AsQueryable()
  1. var source = (from customer in _context.CustomerTBs.    
  2.                 OrderBy(a => a.Country)    
  3.               select customer).AsQueryable(); 
 tell me when above code will execute then records will be fetch from db or not ?
 
  1. var source = (from customer in _context.CustomerTBs.    
  2.                 OrderBy(a => a.Country)    
  3.               select customer).ToList(); 
 when to use AsQueryable() and when to use ToList() ?
 
looking for  answer in details. thanks

Answers (5)