mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 07:13:58 -05:00
update readme
add vision average to client stats other stuff
This commit is contained in:
@ -12,6 +12,10 @@ using System.Threading.Tasks;
|
||||
using System.Globalization;
|
||||
using System.Diagnostics;
|
||||
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using Microsoft.EntityFrameworkCore.Query.Internal;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
|
||||
namespace SharedLibraryCore
|
||||
{
|
||||
public static class Utilities
|
||||
@ -494,5 +498,34 @@ namespace SharedLibraryCore
|
||||
var response = await server.RemoteConnection.SendQueryAsync(RCon.StaticHelpers.QueryType.GET_INFO);
|
||||
return response.FirstOrDefault(r => r[0] == '\\')?.DictionaryFromKeyValue();
|
||||
}
|
||||
|
||||
|
||||
#if DEBUG == true
|
||||
|
||||
private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo();
|
||||
|
||||
private static readonly FieldInfo QueryCompilerField = typeof(EntityQueryProvider).GetTypeInfo().DeclaredFields.First(x => x.Name == "_queryCompiler");
|
||||
|
||||
private static readonly FieldInfo QueryModelGeneratorField = QueryCompilerTypeInfo.DeclaredFields.First(x => x.Name == "_queryModelGenerator");
|
||||
|
||||
private static readonly FieldInfo DataBaseField = QueryCompilerTypeInfo.DeclaredFields.Single(x => x.Name == "_database");
|
||||
|
||||
private static readonly PropertyInfo DatabaseDependenciesField = typeof(Microsoft.EntityFrameworkCore.Storage.Database).GetTypeInfo().DeclaredProperties.Single(x => x.Name == "Dependencies");
|
||||
|
||||
public static string ToSql<TEntity>(this IQueryable<TEntity> query) where TEntity : class
|
||||
{
|
||||
var queryCompiler = (QueryCompiler)QueryCompilerField.GetValue(query.Provider);
|
||||
var modelGenerator = (QueryModelGenerator)QueryModelGeneratorField.GetValue(queryCompiler);
|
||||
var queryModel = modelGenerator.ParseQuery(query.Expression);
|
||||
var database = (IDatabase)DataBaseField.GetValue(queryCompiler);
|
||||
var databaseDependencies = (DatabaseDependencies)DatabaseDependenciesField.GetValue(database);
|
||||
var queryCompilationContext = databaseDependencies.QueryCompilationContextFactory.Create(false);
|
||||
var modelVisitor = (RelationalQueryModelVisitor)queryCompilationContext.CreateQueryModelVisitor();
|
||||
modelVisitor.CreateQueryExecutor<TEntity>(queryModel);
|
||||
var sql = modelVisitor.Queries.First().ToString();
|
||||
|
||||
return sql;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user