5
Answers

What is difference between ToList() & AsQueryable()

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)