Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // problem 6
- public static string GetBooksByCategory(BookShopContext context, string input)
- {
- //Return in a single string the titles of books by a given list of categories.
- //Order by title alphabetically.
- string[] categories = input.Split(' ');
- StringBuilder output = new StringBuilder();
- string[] bookTitles = context
- .Books
- .Where(book => book.BookCategories. ) // the category of the book contains all of the categories listed ??
- // relationship of Books with BooksCategories and Categories
- .Select(book => book.Title)
- .OrderBy(book => book)
- .ToArray();
- foreach(string title in bookTitles)
- {
- output.AppendLine(title);
- }
- return output.ToString().TrimEnd();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement