Сопоставитель .NET 8 EF Include() не работает — возвращает пустой список рейтинговC#

Место общения программистов C#
Anonymous
Сопоставитель .NET 8 EF Include() не работает — возвращает пустой список рейтингов

Сообщение Anonymous »


This is my code that get each type of entreprises and must include the ratings :

public async Task GetTopFiveBytypeyEntreprises() { List hotels = await apiDbContext.Entreprises .Include(e => e.Ratings) // Include Ratings navigation property .Where(x => x.Type.Equals("Hotel")) .OrderByDescending(x => x.Supported) .Take(4) .ToListAsync(); List restaurants = await apiDbContext.Entreprises .Include(e => e.Ratings) // Include Ratings navigation property .Where(x => x.Type.Equals("Restaurant")) .OrderByDescending(x => x.Supported) .Take(4) .ToListAsync(); List activities = await apiDbContext.Entreprises .Include(e => e.Ratings) // Include Ratings navigation property .Where(x => x.Type.Equals("Activity")) .OrderByDescending(x => x.Supported) .Take(4) .ToListAsync(); return new TopFiveTypeDTo() { Hotels = hotels, Restaurant = restaurants, Activities = activities }; } The output doesn't use the .Include() - it just returns an empty list of ratings


Источник: https://stackoverflow.com/questions/780 ... of-ratings

Вернуться в «C#»