public List <OrdersViewModel> ShowAllOrder() { using (BMS_Book_ManagementDBEntities db = new BMS_Book_ManagementDBEntities()) { try { List <Order> allorder = db.Orders.ToList(); var order = new List <OrdersViewModel>(); foreach (var i in allorder) { var d = new OrdersViewModel(i); order.Add(d); } return(order); } catch (Exception ex) { return(null); } } }