Сопоставитель .NET 8 EF Include() не работает — возвращает пустой список рейтингов ⇐ C#
Сопоставитель .NET 8 EF Include() не работает — возвращает пустой список рейтингов
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
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
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Сопоставитель из Mapstruct не сопоставляет список объектов со списком Dto
Anonymous » » в форуме JAVA - 0 Ответы
- 23 Просмотры
-
Последнее сообщение Anonymous
-
-
-
Фатальная ошибка: include/chrono: Нет такого файла или каталога 14 | #include <хроно>
Anonymous » » в форуме C++ - 0 Ответы
- 98 Просмотры
-
Последнее сообщение Anonymous
-