From ebd615c9dcdbd844a47cf4677eb275b8347efff6 Mon Sep 17 00:00:00 2001 From: Svyatoslav Danyliv Date: Thu, 25 Mar 2021 17:32:20 +0200 Subject: [PATCH] Fixed NRT warnings. --- .../LinqToDBExtensionsAdapter.cs | 16 ++++++++++++---- .../LinqToDBForEFExtensions.Async.cs | 8 ++++---- .../LinqToDBForEFTools.ContextExtensions.cs | 1 + .../LinqToDBForEFToolsImplDefault.cs | 4 ++-- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/Source/LinqToDB.EntityFrameworkCore/LinqToDBExtensionsAdapter.cs b/Source/LinqToDB.EntityFrameworkCore/LinqToDBExtensionsAdapter.cs index a40260d..7e4d5db 100644 --- a/Source/LinqToDB.EntityFrameworkCore/LinqToDBExtensionsAdapter.cs +++ b/Source/LinqToDB.EntityFrameworkCore/LinqToDBExtensionsAdapter.cs @@ -87,17 +87,21 @@ public Task FirstAsync( => EntityFrameworkQueryableExtensions.FirstAsync(source, predicate, token); /// - public Task FirstOrDefaultAsync( + public Task FirstOrDefaultAsync( IQueryable source, CancellationToken token) +#pragma warning disable CS8619 // Nullability of reference types in value doesn't match target type. => EntityFrameworkQueryableExtensions.FirstOrDefaultAsync(source, token); +#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type. /// - public Task FirstOrDefaultAsync( + public Task FirstOrDefaultAsync( IQueryable source, Expression> predicate, CancellationToken token) +#pragma warning disable CS8619 // Nullability of reference types in value doesn't match target type. => EntityFrameworkQueryableExtensions.FirstOrDefaultAsync(source, predicate, token); +#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type. /// public Task SingleAsync( @@ -113,17 +117,21 @@ public Task SingleAsync( => EntityFrameworkQueryableExtensions.SingleAsync(source, predicate, token); /// - public Task SingleOrDefaultAsync( + public Task SingleOrDefaultAsync( IQueryable source, CancellationToken token) +#pragma warning disable CS8619 // Nullability of reference types in value doesn't match target type. => EntityFrameworkQueryableExtensions.SingleOrDefaultAsync(source, token); +#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type. /// - public Task SingleOrDefaultAsync( + public Task SingleOrDefaultAsync( IQueryable source, Expression> predicate, CancellationToken token) +#pragma warning disable CS8619 // Nullability of reference types in value doesn't match target type. => EntityFrameworkQueryableExtensions.SingleOrDefaultAsync(source, predicate, token); +#pragma warning restore CS8619 // Nullability of reference types in value doesn't match target type. /// public Task ContainsAsync( diff --git a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFExtensions.Async.cs b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFExtensions.Async.cs index f80e2af..302eef8 100644 --- a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFExtensions.Async.cs +++ b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFExtensions.Async.cs @@ -76,13 +76,13 @@ public static Task FirstAsyncLinqToDB( => AsyncExtensions.FirstAsync(source.ToLinqToDB(), predicate, token); /// - public static Task FirstOrDefaultAsyncLinqToDB( + public static Task FirstOrDefaultAsyncLinqToDB( this IQueryable source, CancellationToken token = default) => AsyncExtensions.FirstOrDefaultAsync(source.ToLinqToDB(), token); /// - public static Task FirstOrDefaultAsyncLinqToDB( + public static Task FirstOrDefaultAsyncLinqToDB( this IQueryable source, Expression> predicate, CancellationToken token = default) @@ -102,13 +102,13 @@ public static Task SingleAsyncLinqToDB( => AsyncExtensions.SingleAsync(source.ToLinqToDB(), predicate, token); /// - public static Task SingleOrDefaultAsyncLinqToDB( + public static Task SingleOrDefaultAsyncLinqToDB( this IQueryable source, CancellationToken token = default) => AsyncExtensions.SingleOrDefaultAsync(source.ToLinqToDB(), token); /// - public static Task SingleOrDefaultAsyncLinqToDB( + public static Task SingleOrDefaultAsyncLinqToDB( this IQueryable source, Expression> predicate, CancellationToken token = default) diff --git a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.ContextExtensions.cs b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.ContextExtensions.cs index c8a5c7c..bff79d3 100644 --- a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.ContextExtensions.cs +++ b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFTools.ContextExtensions.cs @@ -233,6 +233,7 @@ public static async Task BulkCopyAsync( [LinqTunnel] [Pure] public static IValueInsertable Into(this DbContext context, ITable target) + where T: notnull { if (context == null) throw new ArgumentNullException(nameof(context)); if (target == null) throw new ArgumentNullException(nameof(target)); diff --git a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs index c79ba96..fa22507 100644 --- a/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs +++ b/Source/LinqToDB.EntityFrameworkCore/LinqToDBForEFToolsImplDefault.cs @@ -331,7 +331,7 @@ protected virtual IDataProvider CreateSqlServerProvider(SqlServerVersion version { providerName = "Microsoft.Data.SqlClient"; - return DataConnection.GetDataProvider(providerName, connectionString)!; + return DataConnection.GetDataProvider(providerName, connectionString!)!; } switch (version) @@ -364,7 +364,7 @@ protected virtual IDataProvider CreateSqlServerProvider(SqlServerVersion version protected virtual IDataProvider CreatePostgreSqlProvider(PostgreSQLVersion version, string? connectionString) { if (!string.IsNullOrEmpty(connectionString)) - return DataConnection.GetDataProvider(ProviderName.PostgreSQL, connectionString)!; + return DataConnection.GetDataProvider(ProviderName.PostgreSQL, connectionString!)!; string providerName; switch (version)