Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string GetTotalProfitByCategory(BookShopContext context) //12.
- {
- var result = context.Categories
- .OrderByDescending(c => c.CategoryBooks.Select(cb => cb.Book.Copies * cb.Book.Price).Sum())
- .Select(c => $"{c.Name} ${c.CategoryBooks.Select(cb => cb.Book.Copies * cb.Book.Price).Sum():f2}");
- return String.Join(Environment.NewLine, result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement