The coding is as below :
//Get the Detail by grouping with article number, color and category.After looking for the online resources, I find this Article and just realize that it maybe is not about the Group By but the Order By (multiple order by in the group by).
- //Get the Detail by grouping with article number, color and category.
- var DetailGroup = detail.GroupBy(c => new { c.ARTICLE_NUMBER, c.COLOR, c.CATEGORY, c.UOM })
- .OrderByDescending(o => new { o.Key.ARTICLE_NUMBER, o.Key.COLOR }).ToList();
So that, I modify a bit the coding (add in ThenBy) :
- //Get the Detail by grouping with article number, color and category.
- var DetailGroup = detail.GroupBy(c => new { c.ARTICLE_NUMBER, c.COLOR, c.CATEGORY, c.UOM })
- .OrderByDescending(o =>o.Key.ARTICLE_NUMBER).ThenBy( o => o.Key.COLOR ).ToList();
Hope this can help you and have a nice day. :)
--------------------------------------------
This article from: http://oysterleelife.blogspot.sg/2012/11/solved-at-least-one-object-must.html
No comments:
Post a Comment