I'm not sure if I'm doing something wrong or if this is a bug in EF Core 3.1 but the following works with EF 6.x and is part of a Generic Repository which I'm converting to EF Core 3.1:
IQueryable<TEntity> query = this.Context.Set<TEntity>();
if (filter != null)
{
query = query.AsExpandable().Where(filter);
}
if (includeProperties != null)
{
foreach (var includeProperty in includeProperties.Split(new[] { ',' },
StringSplitOptions.RemoveEmptyEntries))
{
query = query.Include(includeProperty);
}
}
but it doesn't work in EF Core 3.1
I've tried changing my "Roles" properties from virtual
to a regular public property but no change and the weird thing is that if I call the following code in my data layer before call the above code:
var test = this.Context
.Users
.Include(u => u.Roles)
.FirstOrDefault(f => f.Username == "xxx@xxx.com");
it works as expected and then if I execute the problematic code, it loads my roles as expected.
Any ideas?
Thanks