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