Skip to content

Commit

Permalink
Merge branch 'version3' into version2
Browse files Browse the repository at this point in the history
# Conflicts:
#	.editorconfig
#	Directory.Build.props
#	Directory.Packages.props
#	NuGet/linq2db.EntityFrameworkCore.nuspec
#	Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs
#	Source/LinqToDB.EntityFrameworkCore/Internal/EFCoreExpressionAttribute.cs
#	Source/LinqToDB.EntityFrameworkCore/Internal/LinqToDBForEFQueryProvider.cs
#	Source/LinqToDB.EntityFrameworkCore/Internal/LinqToDBOptionsExtension.cs
#	Source/LinqToDB.EntityFrameworkCore/LinqToDBExtensionsAdapter.cs
#	Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.ContextExtensions.cs
#	Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.Extensions.cs
#	Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.cs
#	Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsDataConnection.cs
#	Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs
#	Source/LinqToDB.EntityFrameworkCore/linq2db.EntityFrameworkCore.csproj
#	Tests/Directory.Build.props
#	Tests/LinqToDB.EntityFrameworkCore.BaseTests/ForMappingTestsBase.cs
#	Tests/LinqToDB.EntityFrameworkCore.BaseTests/Interceptors/TestEfCoreAndLinqToDBComboInterceptor.cs
#	Tests/LinqToDB.EntityFrameworkCore.BaseTests/Logging/LogMessageEntry.cs
#	Tests/LinqToDB.EntityFrameworkCore.BaseTests/Logging/TestLogger.cs
#	Tests/LinqToDB.EntityFrameworkCore.BaseTests/Logging/TestLoggerProvider.cs
#	Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/Northwind/NorthwindData.Objects.cs
#	Tests/LinqToDB.EntityFrameworkCore.BaseTests/Models/Northwind/NorthwindData.cs
#	Tests/LinqToDB.EntityFrameworkCore.BaseTests/TestsBase.cs
#	Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/ForMappingTests.cs
#	Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests/LinqToDB.EntityFrameworkCore.PomeloMySql.Tests.csproj
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/ForMappingTests.cs
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/ForMapping/ForMappingContext.cs
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/EntityWithXmin.cs
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/Models/NpgSqlEntities/NpgSqlEnititesContext.cs
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/NpgSqlTests.cs
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/AAA.cs
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/Id.cs
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/IdTests.cs
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/ModelBuilderExtensions.cs
#	Tests/LinqToDB.EntityFrameworkCore.PostgreSQL.Tests/SampleTests/StringExtensions.cs
#	Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/ForMappingTests.cs
#	Tests/LinqToDB.EntityFrameworkCore.SQLite.Tests/InterceptorTests.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ForMappingTests.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/JsonConverTests.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Models/ForMapping/ForMappingContext.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Models/IssueModel/IssueContext.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Models/Northwind.Mapping/CustomerCustomerDemoMap.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Models/Northwind.Mapping/CustomerDemographicsMap.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Models/Northwind.Mapping/EmployeeTerritoriesMap.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Models/Northwind.Mapping/RegionMap.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Models/Northwind.Mapping/TerritoriesMap.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Models/Northwind/NorthwindContext.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/Settings.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ToolsTests.cs
#	Tests/LinqToDB.EntityFrameworkCore.SqlServer.Tests/ValueConversion/ConvertorTests.cs
#	azure-pipelines.yml
#	linq2db.EFCore.sln
  • Loading branch information
MaceWindu committed Mar 4, 2024
2 parents 39026e8 + 337a42a commit 727a2a2
Show file tree
Hide file tree
Showing 43 changed files with 965 additions and 850 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>2.13.0</Version>
<Version>2.14.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,24 +1,26 @@
<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.EntityFrameworkCore.Relational" Version="2.2.6" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
<PackageVersion Include="System.Interactive.Async" Version="3.2.0"/>

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

<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="2.2.6" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="2.2.4" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
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 @@ -15,7 +15,7 @@
<license type="file">MIT-LICENSE.txt</license>
<dependencies>
<group targetFramework="netstandard2.0">
<dependency id="linq2db" version="5.3.1" />
<dependency id="linq2db" version="5.4.0" />
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="2.2.6" />
<dependency id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" />
<dependency id="System.Interactive.Async" version="3.2.0" />
Expand Down

This file was deleted.

30 changes: 16 additions & 14 deletions Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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 +121,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 +218,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 @@ -256,15 +256,15 @@ public MappingAttribute[] GetAttributes(Type type, MemberInfo memberInfo)
var annotations = prop.GetAnnotations();
if (_annotationProvider != null)
{
annotations = annotations.Concat(_annotationProvider.For(prop));
annotations = annotations.Concat(_annotationProvider.For(prop)).ToArray();
}

var isIdentity = annotations
.Any(static a =>
{
if (a.Name.EndsWith(":ValueGenerationStrategy"))
{
var value = a.Value?.ToString();
var value = a.Value == null ? null : FormattableString.Invariant($"{a.Value}");

if (value != null && (value.Contains("Identity") || value.Contains("Serial")))
return true;
Expand All @@ -278,7 +278,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 @@ -437,7 +439,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 @@ -587,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 @@ -600,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 @@ -659,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 @@ -121,9 +121,6 @@ public static async Task<BulkCopyRowsCopied> BulkCopyAsync<T>(
if (context == null) throw new ArgumentNullException(nameof(context));
if (source == null) throw new ArgumentNullException(nameof(source));

if (context == null) throw new ArgumentNullException(nameof(context));
if (source == null) throw new ArgumentNullException(nameof(source));

using (var dc = context.CreateLinqToDBConnection())
{
return await dc.BulkCopyAsync(maxBatchSize, source, cancellationToken).ConfigureAwait(Common.Configuration.ContinueOnCapturedContext);
Expand Down Expand Up @@ -170,7 +167,9 @@ public static IValueInsertable<T> Into<T>(this DbContext context, ITable<T> targ
if (context == null) throw new ArgumentNullException(nameof(context));
if (target == null) throw new ArgumentNullException(nameof(target));

#pragma warning disable CA2000 // Dispose objects before losing scope
return context.CreateLinqToDBConnection().Into(target);
#pragma warning restore CA2000 // Dispose objects before losing scope
}

#endregion
Expand All @@ -187,7 +186,9 @@ public static ITable<T> GetTable<T>(this DbContext context)
{
if (context == null) throw new ArgumentNullException(nameof(context));

#pragma warning disable CA2000 // Dispose objects before losing scope
return context.CreateLinqToDBContext().GetTable<T>();
#pragma warning restore CA2000 // Dispose objects before losing scope
}

#endregion
Expand Down Expand Up @@ -217,7 +218,7 @@ public static ITable<T> GetTable<T>(this DbContext context)
{
if (contextOptions == null) throw new ArgumentNullException(nameof(contextOptions));

return contextOptions?.FindExtension<LinqToDBOptionsExtension>()?.Options;
return contextOptions.FindExtension<LinqToDBOptionsExtension>()?.Options;
}

#endregion
Expand Down
Loading

0 comments on commit 727a2a2

Please sign in to comment.