I have the following code in my repository. For some reason, query.Include() method does not work and related entity isn't included in result. Double checked if the property name is correctly passed. Maybe I am using it in wrong way? Any Ideas?
public IEnumerable<TEntity> Get(
Func<TEntity, bool> filter = null,
Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> order = null,
string includedProperties = null)
{
IQueryable<TEntity> query = _context.Set<TEntity>();
if (filter is not null)
{
query = query.Where(filter).AsQueryable();
}
if (order is not null)
{
query = order(query);
}
if (includedProperties is not null)
{
var properties = includedProperties.Split(',', StringSplitOptions.RemoveEmptyEntries);
foreach (var property in properties)
{
query.Include(property);
}
}
return query;
}