Answer the question
In order to leave comments, you need to log in
How to pull data from linq?
I make a type output of products from a certain category. There is the Products entity, into which its category is loaded by eager loading, and the structure turns out like this:
{
"id": 6,
"label": "Opillya Koryfey live light beer 3.7% 0.5l",
"price": 23.49,
"description": "500 ml",
"thumbnail": "https://img3.zakaz.ua/src.1597741190.ad72436478c_2020-08-18_Alina/src.1597741190.SNCPSG10.obj.0.1.jpg.oe.jpg.pf.jpg.150nowm.jpg.150x.jpg",
"category": [
{
"id": 1,
"label": "Beer"
}
]
},
public async Task<IList<Product>> GetProductsByCategory(int offset, int limit,
string searchProperty, string searchValue,
string orderBy, bool desc, int categoryID)
{
return await _context.Set<Product>()
.Include(property => property.ProductCategories)
.ThenInclude(property => property.Category)
//как пройти к Category.Id?
//.Where(property => property.)
.ApplyFiltering(searchProperty, searchValue)
.ApplyOrdering(orderBy, desc)
.Skip(offset)
.Take(limit)
.ToListAsync();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question