entity framework join tables c#
void load_data()
{
DatabaseContext context = new DatabaseContext();
var query = context.books.Include("category").Select(p => new
{
p.id,
p.namebook,
p.Price,
p.picture,
p.categoiryid,
title= p.category.title,
}).OrderByDescending(p => p.id).Take(8).ToList();
ListView1.DataSource = query;
ListView1.DataBind();
} }
<div class="text py-3 pb-4 px-3 text-center">
<h3><a href="#"><%# Eval("namebook")%></a></h3>
<h3><a href="#"> ژانرکتاب:<%# Eval("title")%>0</a></h3>
<div class="d-flex">
<div class="pricing">
<p class="price"><span><%# Eval("price")%> تومان</span></p>
</div>
It is possible that relations between tables are not properly configured. Try this syntax
var query = (from p in context.Set<Book>()
join c in context.Set<Category>()
on p.categoryId equals c.id
select new {
p.id,
p.namebook,
p.Price,
p.picture,
p.categoiryid,
c.titel,
}).OrderByDescending(p => p.id).Take(8).ToList();