Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit c0fb721

Browse files
authored
Update lowest supported linq2db to 5.4.0 (#380)
* - update dependencies - fix analyzer reports - fix non-ivariant culture uses * update icon
1 parent 3f39e42 commit c0fb721

33 files changed

+34934
-34703
lines changed

.editorconfig

Lines changed: 313 additions & 3 deletions
Large diffs are not rendered by default.

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
22
<PropertyGroup>
3-
<Version>8.0.0</Version>
3+
<Version>8.1.0</Version>
44

55
<Authors>Svyatoslav Danyliv, Igor Tkachev, Dmitry Lukashenko, Ilya Chudin</Authors>
66
<Product>Linq to DB</Product>
77
<Company>linq2db.net</Company>
8-
<Copyright>2002-2023 linq2db.net</Copyright>
8+
<Copyright>2002-2024 linq2db.net</Copyright>
99
<RepositoryUrl>https://github.com/linq2db/linq2db.EntityFrameworkCore</RepositoryUrl>
1010
<RepositoryType>git</RepositoryType>
1111

Directory.Packages.props

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<Project>
22
<ItemGroup>
3-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
3+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
44
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
5-
<PackageVersion Include="NUnit" Version="3.14.0" />
5+
<PackageVersion Include="NUnit" Version="4.1.0" />
66
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
77

8-
<PackageVersion Include="linq2db" Version="5.3.2" />
9-
<PackageVersion Include="linq2db.Tools" Version="5.3.2" />
8+
<PackageVersion Include="linq2db" Version="5.4.0" />
9+
<PackageVersion Include="linq2db.Tools" Version="5.4.0" />
10+
11+
<PackageVersion Include="NUnit.Analyzers" Version="4.0.1" />
12+
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.145" />
1013

1114
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
1215

@@ -15,10 +18,10 @@
1518

1619
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
1720

18-
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0-beta.2" />
19-
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="8.0.0" />
20-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
21-
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
21+
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.1" />
22+
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="8.0.2" />
23+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.2" />
24+
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />
2225

2326
<PackageVersion Include="EntityFrameworkCore.FSharp" Version="6.0.7" />
2427
</ItemGroup>

NuGet/icon.png

18.6 KB
Loading

NuGet/linq2db.EntityFrameworkCore.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<title>Linq to DB (linq2db) extensions for Entity Framework Core</title>
66
<authors>Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko</authors>
77
<owners>Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko</owners>
8-
<copyright>Copyright © 2020-2023 Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko</copyright>
8+
<copyright>Copyright © 2020-2024 Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko</copyright>
99
<description>Allows to execute Linq to DB (linq2db) queries in Entity Framework Core DbContext.</description>
1010
<summary />
1111
<tags>linq linq2db LinqToDB ORM database entity-framework-core EntityFrameworkCore EFCore DB SQL SqlServer SqlCe SqlServerCe MySql Firebird SQLite Oracle ODP PostgreSQL DB2</tags>
@@ -16,7 +16,7 @@
1616
<dependencies>
1717
<group targetFramework="net8.0">
1818
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="8.0.0" />
19-
<dependency id="linq2db" version="5.3.2" />
19+
<dependency id="linq2db" version="5.4.0" />
2020
</group>
2121
</dependencies>
2222
</metadata>

Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
namespace LinqToDB.EntityFrameworkCore
2020
{
21+
using System.Globalization;
2122
using Common;
2223
using Expressions;
2324
using Extensions;
@@ -55,7 +56,7 @@ public EFCoreMetadataReader(IModel? model, IInfrastructure<IServiceProvider>? ac
5556
_databaseDependencies = accessor.GetService<DatabaseDependencies>();
5657
}
5758

58-
_objectId = $".{_model?.GetHashCode() ?? 0}.{_dependencies?.GetHashCode() ?? 0}.{_mappingSource?.GetHashCode() ?? 0}.{_annotationProvider?.GetHashCode() ?? 0}.{_logger?.GetHashCode() ?? 0}.";
59+
_objectId = FormattableString.Invariant($".{_model?.GetHashCode() ?? 0}.{_dependencies?.GetHashCode() ?? 0}.{_mappingSource?.GetHashCode() ?? 0}.{_annotationProvider?.GetHashCode() ?? 0}.{_logger?.GetHashCode() ?? 0}.");
5960
}
6061

6162
public MappingAttribute[] GetAttributes(Type type)
@@ -288,7 +289,7 @@ public MappingAttribute[] GetAttributes(Type type, MemberInfo memberInfo)
288289
.Any(static a =>
289290
{
290291
if (a.Name.EndsWith(":ValueGenerationStrategy"))
291-
return a.Value?.ToString()?.Contains("Identity") == true;
292+
return a.Value != null && string.Format(CultureInfo.InvariantCulture, "{0}", a.Value).Contains("Identity");
292293

293294
if (a.Name.EndsWith(":Autoincrement"))
294295
return a.Value is bool b && b;
@@ -629,7 +630,7 @@ string PrepareExpressionText(Expression? expr)
629630
}
630631

631632
if (idx >= 0)
632-
return $"{{{idx}}}";
633+
return FormattableString.Invariant($"{{{idx}}}");
633634

634635
if (expr is SqlFragmentExpression fragment)
635636
return fragment.Sql;
@@ -642,16 +643,16 @@ string PrepareExpressionText(Expression? expr)
642643

643644
if (!sqlFunction.IsNiladic)
644645
{
645-
text = text + "(";
646+
text += "(";
646647
for (var i = 0; i < sqlFunction.Arguments.Count; i++)
647648
{
648649
var paramText = PrepareExpressionText(sqlFunction.Arguments[i]);
649650
if (i > 0)
650-
text = text + ", ";
651-
text = text + paramText;
651+
text += ", ";
652+
text += paramText;
652653
}
653654

654-
text = text + ")";
655+
text += ")";
655656
}
656657

657658
return text;
@@ -666,7 +667,7 @@ string PrepareExpressionText(Expression? expr)
666667
var left = (Expression)newExpression.GetType().GetProperty("Left")!.GetValue(newExpression)!;
667668
var right = (Expression)newExpression.GetType().GetProperty("Right")!.GetValue(newExpression)!;
668669

669-
var operand = newExpression.GetType().GetProperty("OperatorType")!.GetValue(newExpression)!.ToString()!;
670+
var operand = string.Format(CultureInfo.InvariantCulture, "{0}", newExpression.GetType().GetProperty("OperatorType")!.GetValue(newExpression));
670671

671672
var operandExpr = operand switch
672673
{

Source/LinqToDB.EntityFrameworkCore/Internal/EFCoreExpressionAttribute.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Globalization;
34
using System.Linq;
45
using System.Linq.Expressions;
56
using LinqToDB.Mapping;
@@ -47,7 +48,7 @@ public EFCoreExpressionAttribute(string expression) : base(expression)
4748
_ = ResolveExpressionValues((context, @params, knownExpressions, converter), Expression!,
4849
static (ctx, v, d) =>
4950
{
50-
var idx = int.Parse(v);
51+
var idx = int.Parse(v, CultureInfo.InvariantCulture);
5152

5253
if (ctx.@params[idx] == null)
5354
ctx.@params[idx] = ctx.converter(ctx.context, ctx.knownExpressions[idx], null);

Source/LinqToDB.EntityFrameworkCore/Internal/LinqToDBForEFQueryProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ TResult IAsyncQueryProvider.ExecuteAsync<TResult>(Expression expression, Cancell
108108
{
109109
var item = typeof(TResult).GetGenericArguments()[0];
110110
var method = _executeAsyncMethodInfo.MakeGenericMethod(item);
111-
return (TResult)method.Invoke(QueryProvider, new object[] { expression, cancellationToken })!;
111+
return (TResult)method.Invoke(QueryProvider, [expression, cancellationToken])!;
112112
}
113113

114114
/// <summary>

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.Mapping.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,17 @@ static void InitializeMapping()
2525

2626
static Sql.DateParts? GetDatePart(string name)
2727
{
28-
switch (name)
28+
return name switch
2929
{
30-
case "Year" : return Sql.DateParts.Year;
31-
case "Day" : return Sql.DateParts.Day;
32-
case "Month" : return Sql.DateParts.Month;
33-
case "Hour" : return Sql.DateParts.Hour;
34-
case "Minute" : return Sql.DateParts.Minute;
35-
case "Second" : return Sql.DateParts.Second;
36-
case "Millisecond": return Sql.DateParts.Millisecond;
37-
}
38-
39-
return null;
30+
"Year" => (Sql.DateParts?)Sql.DateParts.Year,
31+
"Day" => (Sql.DateParts?)Sql.DateParts.Day,
32+
"Month" => (Sql.DateParts?)Sql.DateParts.Month,
33+
"Hour" => (Sql.DateParts?)Sql.DateParts.Hour,
34+
"Minute" => (Sql.DateParts?)Sql.DateParts.Minute,
35+
"Second" => (Sql.DateParts?)Sql.DateParts.Second,
36+
"Millisecond" => (Sql.DateParts?)Sql.DateParts.Millisecond,
37+
_ => null,
38+
};
4039
}
4140

4241
/// <summary>

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static bool InitializeInternal()
6565
var newExpression = queryable.Expression;
6666

6767
var result = (IQueryable)instantiator.MakeGenericMethod(queryable.ElementType)
68-
.Invoke(null, new object[] { dc, newExpression })!;
68+
.Invoke(null, [dc, newExpression])!;
6969

7070
if (prev != null)
7171
result = prev(result);
@@ -270,7 +270,7 @@ public static DataConnection CreateLinqToDBConnection(this DbContext context,
270270

271271
DataConnection? dc = null;
272272

273-
transaction = transaction ?? context.Database.CurrentTransaction;
273+
transaction ??= context.Database.CurrentTransaction;
274274

275275
var connectionInfo = GetConnectionInfo(info);
276276
var provider = GetDataProvider(options, info, connectionInfo);
@@ -351,7 +351,7 @@ public static IDataContext CreateLinqToDBContext(this DbContext context,
351351

352352
DataConnection? dc = null;
353353

354-
transaction = transaction ?? context.Database.CurrentTransaction;
354+
transaction ??= context.Database.CurrentTransaction;
355355

356356
var connectionInfo = GetConnectionInfo(info);
357357
var provider = GetDataProvider(options, info, connectionInfo);

0 commit comments

Comments
 (0)