I'm wondering what happened to: QueryModelGenerator
, RelationalQueryModelVisitor
and queryCompilationContext.CreateQuerymodelVisitor()
all seems to have vanished.
I have the following code and I'm failing to try to convert it to .NET Core 3 from 2.2
public static string ToSql<TEntity>(this IQueryable<TEntity> query, DbContext dbCtx)
{
var modelGenerator = dbCtx.GetService<IQueryModelGenerator>();
var queryModel = modelGenerator.ParseQuery(query.Expression);
var databaseDependencies = dbCtx.GetService<DatabaseDependencies>();
var queryCompilationContext = databaseDependencies.QueryCompilationContextFactory.Create(false);
var modelVisitor = (RelationalQueryModelVisitor) queryCompilationContext.CreateQueryModelVisitor();
modelVisitor.CreateQueryExecutor<TEntity>(queryModel);
var sql = modelVisitor.Queries.FirstOrDefault()?.ToString();
return sql;
}