Anjali

Anjali

  • NA
  • 7
  • 21.4k

Passing records grouped using group by in LINQ to a MVC View

May 20 2014 12:20 AM
I have a table with products details and i want to group it by supplierId and pass the query result to a MVC view which throws error " The model item passed into the dictionary is of type 'System.Collections.Generic.List`1<>f__AnonymousType`2[System.Int32,System.Linq.IGrouping`2, but this dictionary requires a model item of type" 
My table is:
ProductDetails 
 ProductId
SKU
SupplierId
Package
Price
I want to group it according to the supplier. Pls help me in how to pass the LINQ grouped query result to a MVC view. and how to display the recrds in groups in the View.
TIA. 

Answers (2)