I wrote a generic repo method including all the navigation properties as following:
public async Task<IEnumerable<T>> GetAllWhereAsync(Expression<Func<T, bool>> expression, bool include = false)
{
if (include)
foreach (var name in _db.Model.FindEntityType(typeof(T)).GetNavigations().Select(e => e.Name))
_db.Set<T>().Include(name).Load();
return await _db.Set<T>().AsNoTracking().Where(expression).ToListAsync();
}
However, when I call this method, my resulting entities don't have their navigation property included. What should I do?