Displaying Two tables in the DataGrid

Mar 13 2020 8:11 AM
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.
  1. public partial class AuthorIsbn  
  2. {  
  3. public int AuthorId { getset; }  
  4. public string Isbn { getset; }  
  5. public virtual Authors Author { getset; }  
  6. public virtual Titles IsbnNavigation { getset; }  
  7. }  
TITLES:
  1. public partial class Titles  
  2. {  
  3. public Titles()  
  4. {  
  5. AuthorIsbn = new HashSet<AuthorIsbn>();  
  6. }  
  7. public string Isbn { getset; }  
  8. public string Title { getset; }  
  9. public int EditionNumber { getset; }  
  10. public string Copyright { getset; }  
  11. public virtual ICollection<AuthorIsbn> AuthorIsbn { getset; }  
  12. }  
AUTHORS:
  1. public partial class Authors  
  2. {  
  3. public Authors()  
  4. {  
  5. AuthorIsbn = new HashSet<AuthorIsbn>();  
  6. }  
  7. public int AuthorId { getset; }  
  8. public string FirstName { getset; }  
  9. public string LastName { getset; }  
  10. public virtual ICollection<AuthorIsbn> AuthorIsbn { getset; }  
  11. }  
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.
  1. var list1 = dbContext.Titles.Include(c => c.AuthorIsbn)  
  2. .ThenInclude(z => z.Author)  
  3. .OrderBy(b => b.Title);  
  4. myGrid.ItemsSource = list1.ToList();  
What should I do for the DataGrid to display all the author info?
 
I would really appreciate your help!
Thanks!

Answers (1)