Skip to content

Commit c44302e

Browse files
committed
feat: to ef-core-10
1 parent 14c2cd5 commit c44302e

11 files changed

Lines changed: 57 additions & 24 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,3 +338,6 @@ ASALocalRun/
338338

339339
# Local History for Visual Studio
340340
.localhistory/
341+
342+
#VSCode
343+
.vscode/

.vscode/tasks.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
{
2-
"version": "0.1.0",
2+
"version": "2.0.0",
33
"command": "dotnet",
4-
"isShellCommand": true,
54
"args": [],
65
"tasks": [
76
{
8-
"taskName": "build",
7+
"label": "build",
8+
"type": "shell",
9+
"command": "dotnet",
910
"args": [
11+
"build",
1012
"${workspaceRoot}/test/EFCore.MySql.IntegrationTests/EFCore.MySql.IntegrationTests.csproj"
1113
],
12-
"isBuildCommand": true,
13-
"problemMatcher": "$msCompile"
14+
"problemMatcher": "$msCompile",
15+
"group": {
16+
"_id": "build",
17+
"isDefault": false
18+
}
1419
}
1520
]
1621
}

Directory.Packages.props

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,15 @@
55
-->
66
<EFCoreVersion>[9.0.0,9.0.999]</EFCoreVersion>
77
</PropertyGroup>
8-
98
<ItemGroup Label="Dependencies">
109
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="$(EFCoreVersion)" />
1110
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="$(EFCoreVersion)" />
12-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="$(EFCoreVersion)" />
11+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.0" />
1312
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="$(EFCoreVersion)" />
14-
15-
<PackageVersion Include="MySqlConnector" Version="2.4.0" />
13+
<PackageVersion Include="MySqlConnector" Version="2.5.0" />
1614
<PackageVersion Include="MySqlConnector.DependencyInjection" Version="2.4.0" />
17-
18-
<PackageVersion Include="NetTopologySuite" Version="2.5.0" />
19-
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
20-
15+
<PackageVersion Include="NetTopologySuite" Version="2.6.0" />
16+
<PackageVersion Include="Newtonsoft.Json" Version="13.0.4" />
2117
<PackageVersion Include="Castle.Core" Version="5.1.1" />
2218
<PackageVersion Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.0" />
2319
<PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="9.0.0" />
@@ -28,27 +24,26 @@
2824
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="9.0.0" />
2925
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="9.0.0" />
3026
<PackageVersion Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
31-
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.0" /> <!-- CHECK: used? -->
32-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
27+
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
28+
<!-- CHECK: used? -->
29+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.3" />
3330
<PackageVersion Include="Microsoft.Extensions.DependencyModel" Version="9.0.0" />
3431
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.0" />
3532
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
36-
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
33+
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="10.0.103" />
3734
<PackageVersion Include="Moq" Version="4.20.72" />
3835
<PackageVersion Include="System.Collections.Immutable" Version="9.0.0" />
3936
<PackageVersion Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
4037
<PackageVersion Include="System.Diagnostics.DiagnosticSource" Version="9.0.0" />
4138
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
4239
<PackageVersion Include="Xunit.SkippableFact" Version="1.4.13" />
43-
4440
<!-- Keep at the same level that the EF Core projects use. -->
4541
<PackageVersion Include="xunit.assert" Version="2.9.2" />
4642
<PackageVersion Include="xunit.core" Version="2.9.2" />
4743
<PackageVersion Include="xunit.runner.console" Version="2.9.2" />
4844
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
4945
<PackageVersion Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />
5046
<PackageVersion Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
51-
5247
<!-- Needed when using EFCore.Design assembly from local EF Core repository. -->
5348
<PackageVersion Include="Microsoft.CodeAnalysis" Version="4.10.0" />
5449
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "9.0.100",
3+
"version": "10.0.103",
44
"allowPrerelease": false,
55
"rollForward": "latestFeature"
66
}

src/EFCore.MySql/Query/ExpressionVisitors/Internal/MySqlQuerySqlGenerator.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,14 @@ protected override void GenerateLimitOffset(SelectExpression selectExpression)
249249
}
250250
}
251251

252+
// Single-argument aggregates: generate Name(arg) to match historical SQL shape.
253+
// EF Core 9.x base now generates Name((arg)); we keep the old format for backward compatibility.
254+
private static readonly HashSet<string> SingleArgAggregateFunctions = new(StringComparer.OrdinalIgnoreCase)
255+
{
256+
"AVG", "MAX", "MIN", "SUM", "COUNT", "BIT_AND", "BIT_OR", "BIT_XOR",
257+
"STD", "STDDEV", "STDDEV_POP", "STDDEV_SAMP", "VAR_POP", "VAR_SAMP", "VARIANCE",
258+
};
259+
252260
protected override Expression VisitSqlFunction(SqlFunctionExpression sqlFunctionExpression)
253261
{
254262
if (sqlFunctionExpression.Name.StartsWith("@@", StringComparison.Ordinal))
@@ -258,6 +266,16 @@ protected override Expression VisitSqlFunction(SqlFunctionExpression sqlFunction
258266
return sqlFunctionExpression;
259267
}
260268

269+
if (SingleArgAggregateFunctions.Contains(sqlFunctionExpression.Name)
270+
&& sqlFunctionExpression.Arguments.Count == 1)
271+
{
272+
Sql.Append(sqlFunctionExpression.Name);
273+
Sql.Append("(");
274+
Visit(sqlFunctionExpression.Arguments[0]);
275+
Sql.Append(")");
276+
return sqlFunctionExpression;
277+
}
278+
261279
return base.VisitSqlFunction(sqlFunctionExpression);
262280
}
263281

test/EFCore.MySql.FunctionalTests/Query/EscapesMySqlTestBase.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;
@@ -84,7 +84,9 @@ public virtual async Task Where_contains_query_escapes(bool async)
8484
{
8585
using (var context = CreateContext())
8686
{
87-
var artistNames = new[]
87+
// Use List<string> so Contains binds to Enumerable.Contains; array can bind to
88+
// MemoryExtensions.Contains(ReadOnlySpan) and break the expression interpreter.
89+
var artistNames = new List<string>
8890
{
8991
@"Back\slasher's",
9092
@"John's Chill Box"

test/EFCore.MySql.FunctionalTests/Query/GearsOfWarQueryMySqlTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using System.Linq.Expressions;
45
using System.Threading.Tasks;
@@ -26,7 +27,8 @@ public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async)
2627
var dto = MySqlTestHelpers.GetExpectedValue(new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0)));
2728
var start = dto.AddDays(-1);
2829
var end = dto.AddDays(1);
29-
var dates = new[] { dto };
30+
// Use List to avoid ReadOnlySpan in expression tree (same as EscapesMySqlTestBase).
31+
var dates = new List<DateTimeOffset> { dto };
3032

3133
return AssertQuery(
3234
async,

test/EFCore.MySql.FunctionalTests/Query/TPCGearsOfWarQueryMySqlTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using System.Linq.Expressions;
45
using System.Threading.Tasks;
@@ -9147,7 +9148,8 @@ public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool a
91479148
var dto = MySqlTestHelpers.GetExpectedValue(new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0)));
91489149
var start = dto.AddDays(-1);
91499150
var end = dto.AddDays(1);
9150-
var dates = new[] { dto };
9151+
// Use List to avoid ReadOnlySpan in expression tree (same as GearsOfWarQueryMySqlTest).
9152+
var dates = new List<DateTimeOffset> { dto };
91519153

91529154
await AssertQuery(
91539155
async,

test/EFCore.MySql.FunctionalTests/Query/TPTGearsOfWarQueryMySqlTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using System.Linq.Expressions;
45
using System.Threading.Tasks;
@@ -28,7 +29,8 @@ public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async)
2829
var dto = MySqlTestHelpers.GetExpectedValue(new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0)));
2930
var start = dto.AddDays(-1);
3031
var end = dto.AddDays(1);
31-
var dates = new[] { dto };
32+
// Use List to avoid ReadOnlySpan in expression tree (same as GearsOfWarQueryMySqlTest).
33+
var dates = new List<DateTimeOffset> { dto };
3234

3335
return AssertQuery(
3436
async,

test/EFCore.MySql.FunctionalTests/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Functional Tests
33

44
**Configuring the Database**
55

6+
The functional tests are intended to be run against **MySQL 8.0+** or an equivalent **MariaDB** version (see the main README for tested versions).
7+
68
Configure your MySQL database by opening the `config.json.example` file, specifying the connection string and saving the changed file as `config.json`.
79

810
**Running Functional Tests**

0 commit comments

Comments
 (0)