TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Victor Dallarosa
NA
6
1.1k
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.
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!
Reply
Answers (
1
)
DataGrid Binding async
Drag a point in a WPF diagram?