Reputation: 27
In my database, there are a Book table, a Category table and an Author table. A book has a Category and many Authors. There is an intermediate table between book and author. What I want to do is to bring a list of books to a datagridview.
In case of categories: should I set in the book class, a property: "category id" (int type) or a property: "category" (Category type) or just the "category_name" (String type)?
And in case of the authors: Should I set in the Book class, a property with a list of "authors" (Author type) or a list of "id authors" (int type) or a list of "authors name" (String type)
How should I make the query for bring the books from the database? In case of the authors: Should I make a query to bring all the books and then a query for each book to fill the authors of each?
I'm setting the list of books in the datagridview.datasource.
How do I show the list of books in a datagridview if the book class has included a category property and a property with a list of authors? (In a cell should be all book authors separated by commas)
Upvotes: 0
Views: 75
Reputation: 342
Based on what I have done in one of my application, I suggest as under:
Upvotes: 0
Reputation: 1
Is it too late to start using Entity Framework ?
Entity Framework will do everything for you. You will not care about SQL low level. Of course, you still need to understand the structure and how things are related... but it makes your life much easier.
https://msdn.microsoft.com/en-us/data/jj193542(v=vs.113).aspx
Upvotes: -1