public IEnumerable <AuthorVM> GetAll() { using (context) { try { //SELECT * FROM BOOKS ORDER BY ID DESC var authors = context.Authors.ToList().OrderByDescending(x => x.ID); var authorsVm = authors.Select(x => toViewModel.Author(x)); return(authorsVm); } catch (Exception) { throw; } } }
public IEnumerable <AuthorVM> GetAll() { using (context) { using (var dbTransaction = context.Database.BeginTransaction()) { try { // gets all authors record and order from highest to lowest var authors = context.Authors.ToList().OrderByDescending(x => x.ID); var authorsVm = authors.Select(x => toViewModel.Author(x)); return(authorsVm); } catch (Exception) { throw; } } } }