When I include the Categories table in the seller table with Ef Core, it comes with Product in the Category, I just want the category table to come. There is an overload of data. How can i solve it. Why does Products also appear in Category under Seller only? I just wrote .Include(Category), Products should not come??
The function I included
public async Task<IResponse<Seller>> GetByIdAsyncR(int id)
{
var data = await _context.Sellers.Where(i => i.Id == id)
.Include(i => i.Categories)
.Include(i => i.AppUsers)
.Include(i => i.Products)
.Include(i => i.Orders)
.FirstOrDefaultAsync();
if (data != null)
return new Response<Seller>(ResponseType.Success, data);
return new Response<Seller>(ResponseType.NotFound, "Data bulunamadı");
}
This is the result
{
"email": "a1@a.com",
"offers": [],
"categories": [
"name": "cat1",
"description": "des1",
"language": 0,
"sellerId": 1,
"imageId": null,
"image": null,
"products": [
{
"name": "pd 1",
"language": 0,
"description": "desdesdesdesdesdesdesdesdesdesdesdesdesdesdesdesdesdesdesdes1",
"isStock": true,
"isNew": true,
"sellerId": 1,
"categoryId": 1,
"orderItems": [],
"images": [],
"cardItems": [],
"menuProduct": [],
"id": 1,
"createdDate": "2023-02-13T01:52:17.5190827"
}
],
"id": 1,
"createdDate": "2023-02-13T01:52:17.5190795"
}
I don't understand why Seller->Category->Product is coming? Shouldn't the Products under Category be empty?
I couldn't understand why Products is empty under Category. Shouldn't it be null?