linqgroup-byilist

How can GroupBy ILIST<>


I have a the following query but showing error. how can GroupBy ?

IList<tbl_roadmapautomation> allproductdata = _context.tbl_roadmapautomation.GroupBy(p=>p.Stream).ToList(); 

Here "Stream" is a column name which i want to GroupBy.

ERROR: Cannot implicitly convert type 'System.Collections.Generic.List>' to 'System.Collections.Generic.IList'. An explicit conversion exists (are you missing a cast?)

Please suggest me how can solve this error.Advance thanks for the help.


Solution

  • var allproductdata = 
                _context.tbl_roadmapautomation.GroupBy(p=>p.Stream).ToList(); 
    

    will work

    You need convert from this result to an IList<> (eg, with a cast).

    But I don't think you want to -- IList is just the interface definition, why would you want a list like that?