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

Commit d22e4f8

Browse files
authored
Merge pull request #167 from linq2db/version6
Release 6.0.0
2 parents 2612b06 + 3730e96 commit d22e4f8

33 files changed

+280
-281
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ dotnet_diagnostic.IDE0079.severity = none # IDE0079: Remove unnecessary suppress
251251
dotnet_diagnostic.IDE0080.severity = none # IDE0080: Remove unnecessary suppression operator
252252
dotnet_diagnostic.IDE0081.severity = none # IDE0081: Remove ByVal
253253
dotnet_diagnostic.IDE0083.severity = none # IDE0083: Use pattern matching (not operator)
254+
dotnet_diagnostic.IDE0130.severity = none # IDE0130: Namespace does not match folder structure
254255
dotnet_diagnostic.IDE1006.severity = none # IDE1006: Naming rule violation
255256

256257
dotnet_diagnostic.CS1998.severity = error # CS1998: Async method lacks 'await' operators and will run synchronously

.gitignore

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,8 @@
1-
#ignore thumbnails created by windows
2-
Thumbs.db
3-
#Ignore files build by Visual Studio
4-
*.obj
5-
*.pdb
1+
#Ignore files build by IDE
62
*.user
7-
*.aps
8-
*.pch
9-
*.vspscc
10-
*_i.c
11-
*_p.c
12-
*.ncb
13-
*.suo
14-
*.tlb
15-
*.tlh
16-
*.bak
17-
*.cache
18-
*.ilk
19-
*.log
20-
*.cs.ide
21-
[Bb]in
22-
[Dd]ebug*/
23-
*.lib
24-
*.sbr
3+
bin/
254
obj/
26-
[Rr]elease*/
275
_ReSharper*/
28-
[Tt]est[Rr]esult*
29-
linq2db.sln.docstates
30-
Tests/**/UserDataProviders*.*
31-
NuGet/*.nupkg
32-
!*.dll
33-
!*.exe
34-
!*.pdb
35-
linq2db.sln.ide/graph
36-
linq2db.sln.ide/
37-
!Redist/**
38-
/packages
396
/.vs/*
40-
*.lock.json
41-
/api
42-
/linq2db.github.io
43-
#cake
44-
/tools
45-
/.tools
46-
/.idea/
7+
/.tools/
8+
/.idea/

Build/linq2db.Default.props

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>5.4.1</Version>
3+
<Version>6.0.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-2020 linq2db.net</Copyright>
8+
<Copyright>2002-2021 linq2db.net</Copyright>
99
<RepositoryUrl>https://github.com/linq2db/linq2db.EntityFrameworkCore</RepositoryUrl>
1010
<RepositoryType>git</RepositoryType>
1111

12-
<LangVersion>9.0</LangVersion>
12+
<LangVersion>latest</LangVersion>
1313
<Nullable>enable</Nullable>
1414
<WarningLevel>4</WarningLevel>
1515
<ErrorReport>prompt</ErrorReport>
16-
<AnalysisLevel>preview</AnalysisLevel>
1716

1817
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
1918
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
@@ -28,16 +27,15 @@
2827
<GenerateAssemblyVersionAttribute>true</GenerateAssemblyVersionAttribute>
2928
<GenerateAssemblyFileVersionAttribute>true</GenerateAssemblyFileVersionAttribute>
3029
<GenerateNeutralResourcesLanguageAttribute>false</GenerateNeutralResourcesLanguageAttribute>
30+
31+
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
32+
33+
<TargetFrameworks>net6.0</TargetFrameworks>
3134
</PropertyGroup>
3235

33-
<PropertyGroup>
34-
<AnalysisLevel>preview</AnalysisLevel>
35-
36-
<EnableNETAnalyzers>false</EnableNETAnalyzers>
37-
<RunAnalyzers>false</RunAnalyzers>
38-
</PropertyGroup>
39-
<PropertyGroup Condition=" '$(Configuration)' == 'Azure' OR '$(Configuration)' == 'Release' OR '$(Configuration)' == 'Debug'">
40-
<EnableNETAnalyzers>true</EnableNETAnalyzers>
41-
<RunAnalyzers>true</RunAnalyzers>
42-
</PropertyGroup>
36+
<PropertyGroup>
37+
<AnalysisLevel>preview</AnalysisLevel>
38+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
39+
<RunAnalyzers>true</RunAnalyzers>
40+
</PropertyGroup>
4341
</Project>

Build/linq2db.Tests.props

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
<Project>
22
<Import Project="linq2db.Default.props" />
33

4-
<PropertyGroup>
5-
<!--<TargetFrameworks>net5.0</TargetFrameworks>-->
6-
<TargetFrameworks>netcoreapp3.1</TargetFrameworks>
7-
</PropertyGroup>
8-
94
<ItemGroup>
10-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
11-
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
5+
<PackageReference Include="Microsoft.NET.Test.Sdk" />
6+
<PackageReference Include="NUnit3TestAdapter">
127
<PrivateAssets>all</PrivateAssets>
138
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
149
</PackageReference>
15-
<PackageReference Include="NUnit" Version="3.12.0" />
10+
<PackageReference Include="NUnit" />
1611
</ItemGroup>
1712

1813
</Project>

Directory.Packages.props

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<Project>
2+
<ItemGroup>
3+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
4+
<PackageVersion Include="NUnit3TestAdapter" Version="4.0.0" />
5+
<PackageVersion Include="NUnit" Version="3.13.2" />
6+
<PackageVersion Include="FluentAssertions" Version="5.10.3" />
7+
8+
<PackageVersion Include="linq2db" Version="3.4.2" />
9+
<PackageVersion Include="linq2db.Tools" Version="3.4.2" />
10+
11+
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.0.0" />
12+
13+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0-preview.6.21352.1" />
14+
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0-preview.6.21352.1" />
15+
16+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="6.0.0-preview.6.21352.12" />
17+
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="6.0.0-preview.6.21352.12" />
18+
19+
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.0-preview.5" />
20+
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.0-preview6" />
21+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.0-preview.6.21352.1" />
22+
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0-preview.6.21352.1" />
23+
</ItemGroup>
24+
</Project>

NuGet/linq2db.EntityFrameworkCore.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
<projectUrl>https://github.com/linq2db/linq2db.EntityFrameworkCore</projectUrl>
1515
<license type="file">MIT-LICENSE.txt</license>
1616
<dependencies>
17-
<group targetFramework=".NETStandard2.1">
18-
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="5.0.2" />
17+
<group targetFramework="net6.0">
18+
<dependency id="Microsoft.EntityFrameworkCore.Relational" version="6.0.0-preview.6.21352.1" />
1919
<dependency id="linq2db" version="3.4.2" />
2020
</group>
2121
</dependencies>

Source/LinqToDB.EntityFrameworkCore/EFCoreMetadataReader.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static DataType DbTypeToDataType(DbType dbType)
172172
_ => DataType.Undefined
173173
};
174174
}
175-
175+
176176
public T[] GetAttributes<T>(Type type, MemberInfo memberInfo, bool inherit = true) where T : Attribute
177177
{
178178
if (typeof(Expression).IsSameOrParentOf(type))
@@ -185,14 +185,14 @@ public T[] GetAttributes<T>(Type type, MemberInfo memberInfo, bool inherit = tru
185185
{
186186
var props = et.GetProperties();
187187
var prop = props.FirstOrDefault(p => CompareProperty(p, memberInfo));
188-
188+
189189
if (prop != null)
190190
{
191191
var isPrimaryKey = prop.IsPrimaryKey();
192192
var primaryKeyOrder = 0;
193193
if (isPrimaryKey)
194194
{
195-
var pk = prop.FindContainingPrimaryKey();
195+
var pk = prop.FindContainingPrimaryKey()!;
196196
primaryKeyOrder = pk.Properties.Select((p, i) => new { p, index = i })
197197
.FirstOrDefault(v => CompareProperty(v.p, memberInfo))?.index ?? 0;
198198
}
@@ -202,16 +202,15 @@ public T[] GetAttributes<T>(Type type, MemberInfo memberInfo, bool inherit = tru
202202
var annotations = prop.GetAnnotations();
203203
if (_annotationProvider != null && storeObjectId != null)
204204
{
205-
var column = prop.FindColumn(storeObjectId.Value) as IColumn;
206-
if (column != null)
207-
annotations = annotations.Concat(_annotationProvider.For(column));
205+
if (prop.FindColumn(storeObjectId.Value) is IColumn column)
206+
annotations = annotations.Concat(_annotationProvider.For(column, false));
208207
}
209208

210209
var isIdentity = annotations
211210
.Any(a =>
212211
{
213212
if (a.Name.EndsWith(":ValueGenerationStrategy"))
214-
return a.Value?.ToString().Contains("Identity") == true;
213+
return a.Value?.ToString()!.Contains("Identity") == true;
215214

216215
if (a.Name.EndsWith(":Autoincrement"))
217216
return a.Value is bool b && b;
@@ -411,7 +410,7 @@ protected bool Equals(SqlTransparentExpression other)
411410
return ReferenceEquals(this, other);
412411
}
413412

414-
public override bool Equals(object obj)
413+
public override bool Equals(object? obj)
415414
{
416415
if (obj is null) return false;
417416
if (ReferenceEquals(this, obj)) return true;
@@ -457,7 +456,7 @@ public override int GetHashCode()
457456
Expression.Constant(DefaultValue.GetValue(p.ParameterType), p.ParameterType),
458457
_mappingSource?.FindMapping(p.ParameterType))).ToArray();
459458

460-
var newExpression = _dependencies.MethodCallTranslatorProvider.Translate(_model, objExpr, methodInfo, parametersArray, _logger);
459+
var newExpression = _dependencies.MethodCallTranslatorProvider.Translate(_model, objExpr, methodInfo, parametersArray, _logger!);
461460
if (newExpression != null)
462461
{
463462
if (!methodInfo.IsStatic)
@@ -490,7 +489,7 @@ public override int GetHashCode()
490489
{
491490
var objExpr = new SqlTransparentExpression(Expression.Constant(DefaultValue.GetValue(type), type), _mappingSource?.FindMapping(propInfo));
492491

493-
var newExpression = _dependencies.MemberTranslatorProvider.Translate(objExpr, propInfo, propInfo.GetMemberType(), _logger);
492+
var newExpression = _dependencies.MemberTranslatorProvider.Translate(objExpr, propInfo, propInfo.GetMemberType(), _logger!);
494493
if (newExpression != null)
495494
{
496495
var parametersArray = new Expression[] { objExpr };
@@ -570,7 +569,7 @@ string PrepareExpressionText(Expression? expr)
570569
var left = newExpression.GetType().GetProperty("Left")?.GetValue(newExpression) as Expression;
571570
var right = newExpression.GetType().GetProperty("Right")?.GetValue(newExpression) as Expression;
572571

573-
var operand = newExpression.GetType().GetProperty("OperatorType")?.GetValue(newExpression).ToString();
572+
var operand = newExpression.GetType().GetProperty("OperatorType")?.GetValue(newExpression)!.ToString();
574573

575574
var operandExpr = operand switch
576575
{
@@ -641,7 +640,7 @@ private static Expression UnwrapConverted(Expression expr)
641640
if (expr is SqlFunctionExpression func)
642641
{
643642
if (string.Equals(func.Name, "COALESCE", StringComparison.InvariantCultureIgnoreCase) &&
644-
func.Arguments.Count == 2 && func.Arguments[1].NodeType == ExpressionType.Extension)
643+
func.Arguments!.Count == 2 && func.Arguments[1].NodeType == ExpressionType.Extension)
645644
return UnwrapConverted(func.Arguments[0]);
646645
}
647646

Source/LinqToDB.EntityFrameworkCore/Internal/EFCoreExpressionAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ public override ISqlExpression GetExpression(
3232
{
3333
var mc = (MethodCallExpression) expression;
3434
if (!mc.Method.IsStatic)
35-
knownExpressions.Add(mc.Object);
35+
knownExpressions.Add(mc.Object!);
3636
knownExpressions.AddRange(mc.Arguments);
3737
}
3838
else
3939
{
4040
var me = (MemberExpression) expression;
41-
knownExpressions.Add(me.Expression);
41+
knownExpressions.Add(me.Expression!);
4242
}
4343

4444
var pams = new List<ISqlExpression?>(knownExpressions.Select(_ => (ISqlExpression?) null));

Source/LinqToDB.EntityFrameworkCore/Internal/LinqToDBForEFQueryProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public IQueryable<TElement> CreateQuery<TElement>(Expression expression)
6565
/// </summary>
6666
/// <param name="expression">Query expression.</param>
6767
/// <returns>Query result.</returns>
68-
public object Execute(Expression expression)
68+
public object? Execute(Expression expression)
6969
{
7070
return QueryProvider.Execute(expression);
7171
}
@@ -107,7 +107,7 @@ TResult IAsyncQueryProvider.ExecuteAsync<TResult>(Expression expression, Cancell
107107
{
108108
var item = typeof(TResult).GetGenericArguments()[0];
109109
var method = _executeAsyncMethodInfo.MakeGenericMethod(item);
110-
return (TResult) method.Invoke(QueryProvider, new object[] { expression, cancellationToken });
110+
return (TResult) method.Invoke(QueryProvider, new object[] { expression, cancellationToken })!;
111111
}
112112

113113
/// <summary>
@@ -165,7 +165,7 @@ public IAsyncEnumerator<T> GetAsyncEnumerator(CancellationToken cancellationToke
165165
/// Returns generated SQL for specific LINQ query.
166166
/// </summary>
167167
/// <returns>Generated SQL.</returns>
168-
public override string ToString()
168+
public override string? ToString()
169169
{
170170
return QueryProvider.ToString();
171171
}

Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFExtensions.Async.EF.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static Task<Dictionary<TKey, TSource>> ToDictionaryAsyncEF<TSource, TKey>
3939
this IQueryable<TSource> source,
4040
Func<TSource, TKey> keySelector,
4141
CancellationToken cancellationToken = default)
42+
where TKey: notnull
4243
=> EntityFrameworkQueryableExtensions.ToDictionaryAsync(source, keySelector, cancellationToken);
4344

4445
/// <inheritdoc cref="EntityFrameworkQueryableExtensions.ToDictionaryAsync{TSource, TKey, TElement}(IQueryable{TSource}, Func{TSource, TKey}, Func{TSource, TElement}, CancellationToken)"/>
@@ -47,6 +48,7 @@ public static Task<Dictionary<TKey,TElement>> ToDictionaryAsyncEF<TSource,TKey,T
4748
Func<TSource,TKey> keySelector,
4849
Func<TSource,TElement> elementSelector,
4950
CancellationToken cancellationToken = default)
51+
where TKey : notnull
5052
=> EntityFrameworkQueryableExtensions.ToDictionaryAsync(source, keySelector, elementSelector, cancellationToken);
5153

5254
/// <inheritdoc cref="EntityFrameworkQueryableExtensions.ToDictionaryAsync{TSource, TKey, TElement}(IQueryable{TSource}, Func{TSource, TKey}, Func{TSource, TElement}, IEqualityComparer{TKey}, CancellationToken)"/>
@@ -56,6 +58,7 @@ public static Task<Dictionary<TKey,TElement>> ToDictionaryAsyncEF<TSource,TKey,T
5658
Func<TSource,TElement> elementSelector,
5759
IEqualityComparer<TKey> comparer,
5860
CancellationToken cancellationToken = default)
61+
where TKey : notnull
5962
=> EntityFrameworkQueryableExtensions.ToDictionaryAsync(source, keySelector, elementSelector, comparer, cancellationToken);
6063

6164
/// <inheritdoc cref="EntityFrameworkQueryableExtensions.FirstAsync{TSource}(IQueryable{TSource}, CancellationToken)"/>
@@ -72,13 +75,13 @@ public static Task<TSource> FirstAsyncEF<TSource>(
7275
=> EntityFrameworkQueryableExtensions.FirstAsync(source, predicate, cancellationToken);
7376

7477
/// <inheritdoc cref="EntityFrameworkQueryableExtensions.FirstOrDefaultAsync{TSource}(IQueryable{TSource}, CancellationToken)"/>
75-
public static Task<TSource> FirstOrDefaultAsyncEF<TSource>(
78+
public static Task<TSource?> FirstOrDefaultAsyncEF<TSource>(
7679
this IQueryable<TSource> source,
7780
CancellationToken cancellationToken = default)
7881
=> EntityFrameworkQueryableExtensions.FirstOrDefaultAsync(source, cancellationToken);
7982

8083
/// <inheritdoc cref="EntityFrameworkQueryableExtensions.FirstOrDefaultAsync{TSource}(IQueryable{TSource}, Expression{Func{TSource, bool}}, CancellationToken)"/>
81-
public static Task<TSource> FirstOrDefaultAsyncEF<TSource>(
84+
public static Task<TSource?> FirstOrDefaultAsyncEF<TSource>(
8285
this IQueryable<TSource> source,
8386
Expression<Func<TSource,bool>> predicate,
8487
CancellationToken cancellationToken = default)
@@ -98,13 +101,13 @@ public static Task<TSource> SingleAsyncEF<TSource>(
98101
=> EntityFrameworkQueryableExtensions.SingleAsync(source, predicate, cancellationToken);
99102

100103
/// <inheritdoc cref="EntityFrameworkQueryableExtensions.SingleOrDefaultAsync{TSource}(IQueryable{TSource}, CancellationToken)"/>
101-
public static Task<TSource> SingleOrDefaultAsyncEF<TSource>(
104+
public static Task<TSource?> SingleOrDefaultAsyncEF<TSource>(
102105
this IQueryable<TSource> source,
103106
CancellationToken cancellationToken = default)
104107
=> EntityFrameworkQueryableExtensions.SingleOrDefaultAsync(source, cancellationToken);
105108

106109
/// <inheritdoc cref="EntityFrameworkQueryableExtensions.SingleOrDefaultAsync{TSource}(IQueryable{TSource}, Expression{Func{TSource, bool}}, CancellationToken)"/>
107-
public static Task<TSource> SingleOrDefaultAsyncEF<TSource>(
110+
public static Task<TSource?> SingleOrDefaultAsyncEF<TSource>(
108111
this IQueryable<TSource> source,
109112
Expression<Func<TSource,bool>> predicate,
110113
CancellationToken cancellationToken = default)

0 commit comments

Comments
 (0)