示例#1
0
 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;
         }
     }
 }
示例#2
0
 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;
             }
         }
     }
 }