linq - ASP.NET MVC - Return a List, grouped by a property in my Model -
linq - ASP.NET MVC - Return a List, grouped by a property in my Model -
how homecoming list, grouped property?
in action, homecoming view so:
return view(context.lines.where(x=>x.enquiryid == id).tolist()); this works fine, need grouping these lines particular vehicle. in lines table, has column stores vehicle id particular line linked too. example, line 1 , 2, may have vehicle id of 1, line 3 , 4 may have vehicle id of 2.
do want grouping or order? because if result list of items, you'll want order them properly.
var result = context.lines .where(x => x.enquiryid == id) .orderby(x => x.vehicleid) .tolist(); groupby returns list of lists:
var result = context.lines .where(x => x.enquiryid == id) .groupby(x => x.vehicleid); linq asp.net-mvc-3
Comments
Post a Comment