Skip to content

Commit 9c45cb5

Browse files
committed
fix test issue and bump package version to 2.3.0
1 parent ad39fd7 commit 9c45cb5

File tree

5 files changed

+21
-36
lines changed

5 files changed

+21
-36
lines changed

src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,4 @@
2626
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(NpgsqlPostgreSQLVersion)" />
2727
</ItemGroup>
2828

29-
<ItemGroup>
30-
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="$(EFCoreToolsVersion)" />
31-
</ItemGroup>
32-
3329
</Project>

src/Examples/OperationsExample/OperationsExample.csproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,4 @@
2727
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="$(NpgsqlPostgreSQLVersion)" />
2828
</ItemGroup>
2929

30-
<ItemGroup>
31-
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="$(EFCoreToolsVersion)" />
32-
</ItemGroup>
33-
3430
</Project>

src/JsonApiDotNetCore/JsonApiDotNetCore.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<VersionPrefix>2.2.5</VersionPrefix>
3+
<VersionPrefix>2.3.0</VersionPrefix>
44
<TargetFrameworks>$(NetStandardVersion)</TargetFrameworks>
55
<AssemblyName>JsonApiDotNetCore</AssemblyName>
66
<PackageId>JsonApiDotNetCore</PackageId>

test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/IQueryableExtensions.cs

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,31 @@ namespace JsonApiDotNetCoreExampleTests.Helpers.Extensions
1212
{
1313
public static class IQueryableExtensions
1414
{
15-
private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo();
16-
17-
private static readonly FieldInfo QueryCompilerField = typeof(EntityQueryProvider).GetTypeInfo().DeclaredFields.First(x => x.Name == "_queryCompiler");
15+
private static readonly FieldInfo QueryCompilerField = typeof(EntityQueryProvider).GetTypeInfo().DeclaredFields.Single(x => x.Name == "_queryCompiler");
1816

19-
private static readonly PropertyInfo NodeTypeProviderField = QueryCompilerTypeInfo.DeclaredProperties.Single(x => x.Name == "NodeTypeProvider");
17+
private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo();
2018

21-
private static readonly MethodInfo CreateQueryParserMethod = QueryCompilerTypeInfo.DeclaredMethods.First(x => x.Name == "CreateQueryParser");
19+
private static readonly FieldInfo QueryModelGeneratorField = QueryCompilerTypeInfo.DeclaredFields.Single(x => x.Name == "_queryModelGenerator");
2220

23-
private static readonly FieldInfo DataBaseField = QueryCompilerTypeInfo.DeclaredFields.Single(x => x.Name == "_database");
21+
private static readonly FieldInfo DatabaseField = QueryCompilerTypeInfo.DeclaredFields.Single(x => x.Name == "_database");
2422

25-
private static readonly PropertyInfo DatabaseDependenciesField
26-
= typeof(Database).GetTypeInfo().DeclaredProperties.Single(x => x.Name == "Dependencies");
23+
private static readonly PropertyInfo DependenciesProperty = typeof(Database).GetTypeInfo().DeclaredProperties.Single(x => x.Name == "Dependencies");
2724

28-
public static string ToSql<TEntity>(this IQueryable<TEntity> query) where TEntity : class
25+
public static string ToSql<TEntity>(this IQueryable<TEntity> queryable)
26+
where TEntity : class
2927
{
30-
if (!(query is EntityQueryable<TEntity>) && !(query is InternalDbSet<TEntity>))
31-
{
32-
throw new ArgumentException("Invalid query");
33-
}
34-
35-
var queryCompiler = (IQueryCompiler)QueryCompilerField.GetValue(query.Provider);
36-
var nodeTypeProvider = (INodeTypeProvider)NodeTypeProviderField.GetValue(queryCompiler);
37-
var parser = (IQueryParser)CreateQueryParserMethod.Invoke(queryCompiler, new object[] { nodeTypeProvider });
38-
var queryModel = parser.GetParsedQuery(query.Expression);
39-
var database = DataBaseField.GetValue(queryCompiler);
40-
var queryCompilationContextFactory = ((DatabaseDependencies)DatabaseDependenciesField.GetValue(database)).QueryCompilationContextFactory;
28+
if (!(queryable is EntityQueryable<TEntity>) && !(queryable is InternalDbSet<TEntity>))
29+
throw new ArgumentException();
30+
31+
var queryCompiler = (IQueryCompiler)QueryCompilerField.GetValue(queryable.Provider);
32+
var queryModelGenerator = (IQueryModelGenerator)QueryModelGeneratorField.GetValue(queryCompiler);
33+
var queryModel = queryModelGenerator.ParseQuery(queryable.Expression);
34+
var database = DatabaseField.GetValue(queryCompiler);
35+
var queryCompilationContextFactory = ((DatabaseDependencies)DependenciesProperty.GetValue(database)).QueryCompilationContextFactory;
4136
var queryCompilationContext = queryCompilationContextFactory.Create(false);
4237
var modelVisitor = (RelationalQueryModelVisitor)queryCompilationContext.CreateQueryModelVisitor();
4338
modelVisitor.CreateQueryExecutor<TEntity>(queryModel);
44-
var sql = modelVisitor.Queries.First().ToString();
45-
46-
return sql;
39+
return modelVisitor.Queries.Join(Environment.NewLine + Environment.NewLine);
4740
}
4841
}
49-
}
42+
}

test/JsonApiDotNetCoreExampleTests/Helpers/Extensions/StringExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace JsonApiDotNetCoreExampleTests.Helpers.Extensions
44
{
5-
65
public static class StringExtensions
76
{
87
public static string Normalize(this string input)
98
{
109
return Regex.Replace(input, @"\s+", string.Empty)
1110
.ToUpper()
12-
.Replace('"', '\'');
11+
.Replace("\"", string.Empty)
12+
.Replace("'", string.Empty);
1313
}
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)