Anjali

Anjali

  • NA
  • 7
  • 21.4k

Error passing linq result to MVC view.

Feb 11 2014 1:55 AM
this is my controller
 
public ActionResult Comments(int? Id)
 { var abccomment= db.xyzComments.Include(c=>c.XYZMasters); 
var comments = (from x in abccomment        
                 where Id == x.CcId select x.Comment).Distinct().ToList();
 return View(comments); } 
 
this is my view
 
@model IEnumerable<farma.Models.XYZMaster> 

@foreach (var item in Model)
 { @item.XYZComment.Comment }
 i get the following error...
 
he model item passed into the dictionary is of type 'System.Collections.Generic.List1[System.String]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable1[farma.Models.XYZMaster].
 
I am new to MVC C#, so pls help .. Thanks