I would like to ask how I could make a query to select the genre for each book, I tried many ways to do this, but I failed.
Book:
public class Book
{
public int Id { get; set; }
[StringLength(100)]
public string Title { get; set; }
public virtual ICollection<Genre> Genres { get; set; }
public virtual Author Author { get; set; }
}
Genre:
public class Genre
{
public int Id { get; set; }
[StringLength(32)]
public string Name { get; set; }
public virtual ICollection<Book> Books { get; set; }
}
Author:
public class Author
{
public int Id { get; set; }
public string FullName { get; set; }
public virtual ICollection<Book> Books { get; set; }
}
What I tried: (I marked with "?" Where I can no longer do)
from book in Books
join author in Authors on book.Author.Id equals author.Id
??join Genre ??
select new {book, author, ?list genres}