Amit Kumar

Amit Kumar

  • NA
  • 57
  • 1.4k

How can i select specific records from database in asp MVC?

Nov 6 2017 8:22 AM
In the following code, I want to retrieve all those records whose Q_ID equals to the ID.
Currently, I Select whole records instead of few.
 
Please help me to solve this problem.
  1. public ActionResult Solution(int ID)  
  2. {  
  3. Answers ans_obj = new Answers();  
  4. List<Ans_Table> dbobj= db.Ans_Table.ToList();  
  5. List<Answers> ansobj = dbobj.Select(x => new Answers  
  6. {  
  7. Answer = x.Answer,  
  8. Q_ID=x.Q_ID,  
  9. U_ID=x.U_ID  
  10. }).ToList();  
  11. return View();  
  12. }

Answers (1)