我想找出什么方法可以使用EAGER LOADING代替下面的代码部分的JOINS? 对于所有JOINS陈述,我想知道这一点。 关系很清楚,但是如果您对关系有疑问,请询问
var Books = (from b in _context.Books
//Join Publisher VS Books
join p in _context.Publishers on b.PublisherID equals p.PublisherID
//Join Authors VS Books
join u in _context.Author_Books on b.BookID equals u.BookID
join a in _context.Authors on u.AuthorID equals a.AuthorID
//Full Outer Join Translators VS Books
join bt in _context.Book_Translators on b.BookID equals bt.BookID into btx
from bts in btx.DefaultIfEmpty()
join t in _context.Translators on bts.TranslatorID equals t.TranslatorID into ftx
from ft in ftx.DefaultIfEmpty()
//Full Outer Join Categories VS Books
join cb in _context.Book_Categories on b.BookID equals cb.BookID into fcbx
from fcb in fcbx.DefaultIfEmpty()
join c in _context.Categories on fcb.CategoryID equals c.CategoryID into fcx
from fc in fcx.DefaultIfEmpty()
//Join Languages VS Books
join l in _context.Languages on b.LanguageID equals l.LanguageID
where b.Delete != true && b.Title.Contains(Title.TrimStart().TrimEnd())
&& b.ISBN.Contains(ISBN.TrimStart().TrimEnd())
&& b.Language.LanguageName.Contains(Language.TrimStart().TrimEnd())
&& b.Publisher.PublisherName.Contains(Publisher.TrimStart().TrimEnd())
select new
{
b.BookID,
b.Title,
b.ISBN,
b.Price,
b.PublishDate,
b.IsPublish,
p.PublisherName,
Author= a.FirstName + " " + a.LastName,
b.Stock,
TranslatorFullName = bts != null ? ft.Name + " " + ft.Family : "",
//Category = fcb != null ? fc.CategoryName : "",
Category = fc.CategoryName,
l.LanguageName,
}).Where(a=>a.Author.Contains(Author) && a.TranslatorFullName.Contains(Translator) && a.Category.Contains(Category))
.GroupBy(b=>b.BookID)
.Select(g => new { BookID = g.Key, BookGroups = g });