Skip to content

Commit

Permalink
Update lowest supported linq2db to 5.4.0 (#380)
Browse files Browse the repository at this point in the history
* - update dependencies

- fix analyzer reports
- fix non-ivariant culture uses

* update icon
  • Loading branch information
MaceWindu committed Mar 4, 2024
1 parent 3f39e42 commit c0fb721
Show file tree
Hide file tree
Showing 33 changed files with 34,934 additions and 34,703 deletions.
316 changes: 313 additions & 3 deletions .editorconfig

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Version>8.0.0</Version>
<Version>8.1.0</Version>

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

Expand Down
19 changes: 11 additions & 8 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<Project>
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="NUnit" Version="3.14.0" />
<PackageVersion Include="NUnit" Version="4.1.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />

<PackageVersion Include="linq2db" Version="5.3.2" />
<PackageVersion Include="linq2db.Tools" Version="5.3.2" />
<PackageVersion Include="linq2db" Version="5.4.0" />
<PackageVersion Include="linq2db.Tools" Version="5.4.0" />

<PackageVersion Include="NUnit.Analyzers" Version="4.0.1" />
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.145" />

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

Expand All @@ -15,10 +18,10 @@

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

<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0-beta.2" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.1" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="8.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.2" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />

<PackageVersion Include="EntityFrameworkCore.FSharp" Version="6.0.7" />
</ItemGroup>
Expand Down
Binary file modified NuGet/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions NuGet/linq2db.EntityFrameworkCore.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<title>Linq to DB (linq2db) extensions for Entity Framework Core</title>
<authors>Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko</authors>
<owners>Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko</owners>
<copyright>Copyright © 2020-2023 Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko</copyright>
<copyright>Copyright © 2020-2024 Igor Tkachev, Ilya Chudin, Svyatoslav Danyliv, Dmitry Lukashenko</copyright>
<description>Allows to execute Linq to DB (linq2db) queries in Entity Framework Core DbContext.</description>
<summary />
<tags>linq linq2db LinqToDB ORM database entity-framework-core EntityFrameworkCore EFCore DB SQL SqlServer SqlCe SqlServerCe MySql Firebird SQLite Oracle ODP PostgreSQL DB2</tags>
Expand All @@ -16,7 +16,7 @@
<dependencies>
<group targetFramework="net8.0">
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="8.0.0" />
<dependency id="linq2db" version="5.3.2" />
<dependency id="linq2db" version="5.4.0" />
</group>
</dependencies>
</metadata>
Expand Down
17 changes: 9 additions & 8 deletions Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

namespace LinqToDB.EntityFrameworkCore
{
using System.Globalization;
using Common;
using Expressions;
using Extensions;
Expand Down Expand Up @@ -55,7 +56,7 @@ public EFCoreMetadataReader(IModel? model, IInfrastructure<IServiceProvider>? ac
_databaseDependencies = accessor.GetService<DatabaseDependencies>();
}

_objectId = $".{_model?.GetHashCode() ?? 0}.{_dependencies?.GetHashCode() ?? 0}.{_mappingSource?.GetHashCode() ?? 0}.{_annotationProvider?.GetHashCode() ?? 0}.{_logger?.GetHashCode() ?? 0}.";
_objectId = FormattableString.Invariant($".{_model?.GetHashCode() ?? 0}.{_dependencies?.GetHashCode() ?? 0}.{_mappingSource?.GetHashCode() ?? 0}.{_annotationProvider?.GetHashCode() ?? 0}.{_logger?.GetHashCode() ?? 0}.");
}

public MappingAttribute[] GetAttributes(Type type)
Expand Down Expand Up @@ -288,7 +289,7 @@ public MappingAttribute[] GetAttributes(Type type, MemberInfo memberInfo)
.Any(static a =>
{
if (a.Name.EndsWith(":ValueGenerationStrategy"))
return a.Value?.ToString()?.Contains("Identity") == true;
return a.Value != null && string.Format(CultureInfo.InvariantCulture, "{0}", a.Value).Contains("Identity");
if (a.Name.EndsWith(":Autoincrement"))
return a.Value is bool b && b;
Expand Down Expand Up @@ -629,7 +630,7 @@ string PrepareExpressionText(Expression? expr)
}

if (idx >= 0)
return $"{{{idx}}}";
return FormattableString.Invariant($"{{{idx}}}");

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

if (!sqlFunction.IsNiladic)
{
text = text + "(";
text += "(";
for (var i = 0; i < sqlFunction.Arguments.Count; i++)
{
var paramText = PrepareExpressionText(sqlFunction.Arguments[i]);
if (i > 0)
text = text + ", ";
text = text + paramText;
text += ", ";
text += paramText;
}

text = text + ")";
text += ")";
}

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

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

var operandExpr = operand switch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using LinqToDB.Mapping;
Expand Down Expand Up @@ -47,7 +48,7 @@ public EFCoreExpressionAttribute(string expression) : base(expression)
_ = ResolveExpressionValues((context, @params, knownExpressions, converter), Expression!,
static (ctx, v, d) =>
{
var idx = int.Parse(v);
var idx = int.Parse(v, CultureInfo.InvariantCulture);
if (ctx.@params[idx] == null)
ctx.@params[idx] = ctx.converter(ctx.context, ctx.knownExpressions[idx], null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ TResult IAsyncQueryProvider.ExecuteAsync<TResult>(Expression expression, Cancell
{
var item = typeof(TResult).GetGenericArguments()[0];
var method = _executeAsyncMethodInfo.MakeGenericMethod(item);
return (TResult)method.Invoke(QueryProvider, new object[] { expression, cancellationToken })!;
return (TResult)method.Invoke(QueryProvider, [expression, cancellationToken])!;
}

/// <summary>
Expand Down
21 changes: 10 additions & 11 deletions Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.Mapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,17 @@ static void InitializeMapping()

static Sql.DateParts? GetDatePart(string name)
{
switch (name)
return name switch
{
case "Year" : return Sql.DateParts.Year;
case "Day" : return Sql.DateParts.Day;
case "Month" : return Sql.DateParts.Month;
case "Hour" : return Sql.DateParts.Hour;
case "Minute" : return Sql.DateParts.Minute;
case "Second" : return Sql.DateParts.Second;
case "Millisecond": return Sql.DateParts.Millisecond;
}

return null;
"Year" => (Sql.DateParts?)Sql.DateParts.Year,
"Day" => (Sql.DateParts?)Sql.DateParts.Day,
"Month" => (Sql.DateParts?)Sql.DateParts.Month,
"Hour" => (Sql.DateParts?)Sql.DateParts.Hour,
"Minute" => (Sql.DateParts?)Sql.DateParts.Minute,
"Second" => (Sql.DateParts?)Sql.DateParts.Second,
"Millisecond" => (Sql.DateParts?)Sql.DateParts.Millisecond,
_ => null,
};
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static bool InitializeInternal()
var newExpression = queryable.Expression;
var result = (IQueryable)instantiator.MakeGenericMethod(queryable.ElementType)
.Invoke(null, new object[] { dc, newExpression })!;
.Invoke(null, [dc, newExpression])!;
if (prev != null)
result = prev(result);
Expand Down Expand Up @@ -270,7 +270,7 @@ public static DataConnection CreateLinqToDBConnection(this DbContext context,

DataConnection? dc = null;

transaction = transaction ?? context.Database.CurrentTransaction;
transaction ??= context.Database.CurrentTransaction;

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

DataConnection? dc = null;

transaction = transaction ?? context.Database.CurrentTransaction;
transaction ??= context.Database.CurrentTransaction;

var connectionInfo = GetConnectionInfo(info);
var provider = GetDataProvider(options, info, connectionInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ object IEntityServiceInterceptor.EntityCreated(EntityCreatedEventData eventData,
body = Expression.Condition(checkExpression, invalidResult, body);
}

body = Expression.Block(new[] { variable }, assignExpr, body);
body = Expression.Block([variable], assignExpr, body);

var lambda =
Expression.Lambda<Func<IStateManager, object, Tuple<InternalEntityEntry?, bool>>>(body, stateManagerParam, objParam);
Expand Down
Loading

0 comments on commit c0fb721

Please sign in to comment.