EF Core 3.1 I have seen Specification example, and want to implement ThenInclude pattern.
public static class QuerySpecificationExtensions
{
public static IQueryable<T> Specify<T>(this IQueryable<T> query, ISpecification<T> spec) where T : class
{
// fetch a Queryable that includes all expression-based includes
var queryableResultWithIncludes = spec.Includes
.Aggregate(query,
(current, include) => current.Include(include));
// modify the IQueryable to include any string-based include statements
var secondaryResult = spec.IncludeStrings
.Aggregate(queryableResultWithIncludes,
(current, include) => current.Include(include));
// return the result of the query using the specification's criteria expression
return secondaryResult.Where(spec.Criteria);
}
}
I can add this into string for example "User.UserRole.Role", but I want to implement object. Maybe there it is not possible?