Hello Guys,
I am really struggling here to display both the results in my WPF Table.
Question: Get a list of all the titles and the authors who wrote them. Sort the results by title.
I have three tables in my Database, AuthorISBN, Authors and Titles.
AuthorsISBN has both the FK for the other two.
- public partial class AuthorIsbn
- {
- public int AuthorId { get; set; }
- public string Isbn { get; set; }
- public virtual Authors Author { get; set; }
- public virtual Titles IsbnNavigation { get; set; }
- }
TITLES:
- public partial class Titles
- {
- public Titles()
- {
- AuthorIsbn = new HashSet<AuthorIsbn>();
- }
- public string Isbn { get; set; }
- public string Title { get; set; }
- public int EditionNumber { get; set; }
- public string Copyright { get; set; }
- public virtual ICollection<AuthorIsbn> AuthorIsbn { get; set; }
- }
AUTHORS:
- public partial class Authors
- {
- public Authors()
- {
- AuthorIsbn = new HashSet<AuthorIsbn>();
- }
- public int AuthorId { get; set; }
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public virtual ICollection<AuthorIsbn> AuthorIsbn { get; set; }
- }
In my WPF Application I have a DataGrid and when I press a button it displays the information, the problem is that it's only displaying information from one table, the Titles table.
- var list1 = dbContext.Titles.Include(c => c.AuthorIsbn)
- .ThenInclude(z => z.Author)
- .OrderBy(b => b.Title);
- myGrid.ItemsSource = list1.ToList();
What should I do for the DataGrid to display all the author info?
I would really appreciate your help!
Thanks!