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

Popular posts from this blog

delphi - blogger via idHTTP : error 400 bad request -

c++ - compiler errors when initializing EXPECT_CALL with function which has program_options::variables_map as parameter -

How do I check if an insert was successful with MySQLdb in Python? -