Let's say I have a service called BookService, and I have method called GetAllBooks, GetBookById, and so on. Now I want to get all books that are recently modified, so do I need another method? or should I useGetAllBooks().Where(....)?
And in the code below, is there a difference between GetBooksByAuthorA and GetBooksByAuthorB?
public List<Book> GetAllBooks() { return _context.Books.ToList(); } public List<Book> GetBooksByAuthorA(string author) { return _context.Books.Where(a => a.Author == author); } public List<Book> GetBooksByAuthorB(string author) { return GetAllBooks().Where(a => a.Author == author); }
PS: The code above is not tested and I only write it as an example of what point I'm trying to tell.