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

(cherry picked from commit c0fb721)

# Conflicts:
#	.editorconfig
#	Directory.Build.props
#	Directory.Packages.props
#	NuGet/linq2db.EntityFrameworkCore.nuspec
#	Tests/LinqToDB.EntityFrameworkCore.BaseTests/Logging/TestLogger.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/JsonConverTests.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ToolsTests.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ValueConversion/ConvertorTests.cs
#	azure-pipelines.yml
(cherry picked from commit d253150)

# Conflicts:
#	Directory.Build.props
#	Directory.Packages.props
#	NuGet/linq2db.EntityFrameworkCore.nuspec
#	Source/LinqToDB.EntityFrameworkCore/Internal/LinqToDBForEFQueryProvider.cs
#	Tests/LinqToDB.EntityFrameworkCore.BaseTests/Logging/TestLogger.cs
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/AAA.cs
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/StringExtensions.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Settings.cs
#	azure-pipelines.yml
(cherry picked from commit 1ac0155)

# Conflicts:
#	Directory.Build.props
#	Directory.Packages.props
#	NuGet/linq2db.EntityFrameworkCore.nuspec
#	Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.cs
#	Tests/LinqToDB.EntityFrameworkCore.BaseTests/ForMappingTestsBase.cs
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/AAA.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ToolsTests.cs
#	azure-pipelines.yml
(cherry picked from commit 3c27d7f)

# Conflicts:
#	Directory.Build.props
#	Directory.Packages.props
#	NuGet/linq2db.EntityFrameworkCore.nuspec
#	Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs
#	Tests/LinqToDB.EntityFrameworkCore.FSharpTests/LinqToDB.EntityFrameworkCore.FSharpTests.fsproj
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/AAA.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/JsonConverTests.cs
#	azure-pipelines.yml
  • Loading branch information
MaceWindu committed Mar 4, 2024
1 parent 8dcc1f2 commit 337a42a
Show file tree
Hide file tree
Showing 45 changed files with 35,137 additions and 35,081 deletions.
328 changes: 325 additions & 3 deletions .editorconfig

Large diffs are not rendered by default.

6 changes: 3 additions & 3 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>3.26.0</Version>
<Version>3.27.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 All @@ -29,7 +29,7 @@
<GenerateAssemblyVersionAttribute>true</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>true</GenerateAssemblyFileVersionAttribute>
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>
<DisableImplicitNamespaceImports>true</DisableImplicitNamespaceImports>

<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>

Expand Down
16 changes: 9 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<Project>
<ItemGroup>
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageVersion Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageVersion Include="NUnit" Version="3.13.3" />
<PackageVersion Include="NUnit" Version="3.14.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />

<PackageVersion Include="linq2db" Version="5.3.1" />
<PackageVersion Include="linq2db.Tools" Version="5.3.1" />
<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="1.1.1" />
<PackageVersion Include="PolySharp" Version="1.13.2" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="6.0.0" />

<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.25" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.25" />

<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.25" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />

<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="3.2.7" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="3.1.18" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.32" />
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="netstandard2.0">
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="3.1.25" />
<dependency id="linq2db" version="5.3.1" />
<dependency id="linq2db" version="5.4.0" />
</group>
</dependencies>
</metadata>
Expand Down

This file was deleted.

29 changes: 16 additions & 13 deletions Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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

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

public MappingAttribute[] GetAttributes(Type type)
Expand Down Expand Up @@ -121,10 +122,10 @@ public MappingAttribute[] GetAttributes(Type type)
// TableAttribute
var tableAttribute = type.GetAttribute<System.ComponentModel.DataAnnotations.Schema.TableAttribute>();
if (tableAttribute != null)
(result ??= new()).Add(new TableAttribute(tableAttribute.Name) { Schema = tableAttribute.Schema });
(result = new()).Add(new TableAttribute(tableAttribute.Name) { Schema = tableAttribute.Schema });
}

return result == null ? Array.Empty<MappingAttribute>() : result.ToArray();
return result == null ? [] : result.ToArray();
}

static IEntityType GetBaseTypeRecursive(IEntityType entityType)
Expand Down Expand Up @@ -218,7 +219,7 @@ static DataType DbTypeToDataType(DbType dbType)
public MappingAttribute[] GetAttributes(Type type, MemberInfo memberInfo)
{
if (typeof(Expression).IsSameOrParentOf(type))
return Array.Empty<MappingAttribute>();
return [];

List<MappingAttribute>? result = null;
var hasColumn = false;
Expand Down Expand Up @@ -263,7 +264,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 All @@ -273,7 +274,9 @@ public MappingAttribute[] GetAttributes(Type type, MemberInfo memberInfo)
{
if (a.Value is string str)
{
return str.ToLowerInvariant().Contains("nextval");
#pragma warning disable CA1862 // Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
return str.ToUpperInvariant().Contains("NEXTVAL");
#pragma warning restore CA1862 // Use the 'StringComparison' method overloads to perform case-insensitive string comparisons
}
}
Expand Down Expand Up @@ -429,7 +432,7 @@ public MappingAttribute[] GetAttributes(Type type, MemberInfo memberInfo)
});
}

return result == null ? Array.Empty<MappingAttribute>() : result.ToArray();
return result == null ? [] : result.ToArray();
}

sealed class ValueConverter : IValueConverter
Expand Down Expand Up @@ -586,7 +589,7 @@ string PrepareExpressionText(Expression? expr)
}

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

if (expr is SqlFragmentExpression fragment)
return fragment.Sql;
Expand All @@ -599,16 +602,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 Down Expand Up @@ -658,7 +661,7 @@ private static Expression UnwrapConverted(Expression expr)

public MemberInfo[] GetDynamicColumns(Type type)
{
return Array.Empty<MemberInfo>();
return [];
}

string IMetadataReader.GetObjectID() => _objectId;
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 All @@ -10,7 +11,7 @@ namespace LinqToDB.EntityFrameworkCore.Internal
/// <summary>
/// Maps Linq To DB expression.
/// </summary>
public class EFCoreExpressionAttribute : Sql.ExpressionAttribute
public sealed class EFCoreExpressionAttribute : Sql.ExpressionAttribute
{
/// <summary>
/// Creates instance of expression mapper.
Expand Down Expand Up @@ -47,7 +48,7 @@ public EFCoreExpressionAttribute(string expression) : base(expression)
_ = ResolveExpressionValues((context, parms, knownExpressions, converter), Expression!,
static (ctx, v, d) =>
{
var idx = int.Parse(v);
var idx = int.Parse(v, CultureInfo.InvariantCulture);
if (ctx.parms[idx] == null)
ctx.parms[idx] = ctx.converter(ctx.context, ctx.knownExpressions[idx], null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,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
Loading

0 comments on commit 337a42a

Please sign in to comment.