Vidhi Patel

Vidhi Patel

  • NA
  • 44
  • 16.9k

I want to the controller in my sql query

Nov 14 2016 3:30 AM
Here is my controlller n above the first i put the sql function which i created.but in table Allocation filed data type is int so i have to convert that in double.
 
i want sql query which i display after execplian the things after write.
 
That function how to write in my controller plz guide me.
 

 
SELECT SID, RID, Schema_Name, SType, InvestmentType, Allocation, Lum_Sum_Amount,
Allocation /100.0 * Lum_Sum_Amount as total
FROM Schema_Details where RID = 1

 
this is my controller with method.....
  1. public ActionResult recommendedportfolio()  
  2. {  
  3. using (var db = new WFTradeEntities())  
  4. {  
  5. return View(db.Schema_Details.ToList());  
  6. }  
  7. }  
  8. [HttpPost]  
  9. public ActionResult recommendedportfolio(int sName)  
  10. {  
  11. using (var db = new WFTradeEntities())  
  12. {  
  13. var total = db.Schema_Details.Where(x => x.RID == sName)  
  14. .Select(x => new  
  15. {  
  16. Rid = x.RID,  
  17. Amount = Convert.ToDouble(x.Lum_Sum_Amount),  
  18. Allocation = Convert.ToDouble(x.Allocation),  
  19. total = ((x.Allocation / 100) * x.Lum_Sum_Amount)  
  20. }).ToList();  
  21. return PartialView("_PortfolioTable", total);  
  22. }  
  23. }  
and I am getting this error how can i solve it..
 

Answers (1)