diff --git a/demo/AspNetCore5.0/AspNetCore5.0.csproj b/demo/AspNetCore5.0/AspNetCore5.0.csproj index f26911c..5cd5d02 100644 --- a/demo/AspNetCore5.0/AspNetCore5.0.csproj +++ b/demo/AspNetCore5.0/AspNetCore5.0.csproj @@ -16,8 +16,7 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - + diff --git a/src/TanvirArjel.EFCore.GenericRepository/TanvirArjel.EFCore.GenericRepository.csproj b/src/TanvirArjel.EFCore.GenericRepository/TanvirArjel.EFCore.GenericRepository.csproj index 76756aa..b0952ea 100644 --- a/src/TanvirArjel.EFCore.GenericRepository/TanvirArjel.EFCore.GenericRepository.csproj +++ b/src/TanvirArjel.EFCore.GenericRepository/TanvirArjel.EFCore.GenericRepository.csproj @@ -1,7 +1,7 @@  - netstandard2.1;net6.0;net7.0 + netstandard2.1;net6.0; 8.0 true true @@ -43,9 +43,9 @@ Git EFCore, RepositoryLayer, GenericRepository, UnitOfWork, .NET, .NETCore, ASP.NETCore - 1. Multiple DbConext support has been added. + 1. SQL connection closing isssue has been fixed. - 6.0.0-preview1 + 5.9.1 LICENSE icon.png TanvirArjel @@ -73,9 +73,9 @@ - + diff --git a/src/TanvirArjel.EFCore.QueryRepository/SqlQueryExtensions.cs b/src/TanvirArjel.EFCore.QueryRepository/SqlQueryExtensions.cs index 692f258..b83581d 100644 --- a/src/TanvirArjel.EFCore.QueryRepository/SqlQueryExtensions.cs +++ b/src/TanvirArjel.EFCore.QueryRepository/SqlQueryExtensions.cs @@ -4,17 +4,12 @@ using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations.Schema; -using System.Data; using System.Data.Common; using System.Globalization; -using System.Linq; using System.Reflection; using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage; namespace TanvirArjel.EFCore.GenericRepository { @@ -168,111 +163,5 @@ public static async Task> GetFromQueryAsync( await dbContext.Database.CloseConnectionAsync(); } } - - private static async Task> GetFromQueryAsync2( - this DbContext dbContext, - string sql, - IEnumerable parameters, - CancellationToken cancellationToken = default) - { - RelationalDataReader relationalDataReader = await dbContext.ExecuteSqlQueryAsync(sql, parameters, cancellationToken); - using DbDataReader dr = relationalDataReader.DbDataReader; - - List list = new List(); - T t = default; - while (await dr.ReadAsync(cancellationToken)) - { - if (!(typeof(T).IsPrimitive || typeof(T).Equals(typeof(string)))) - { - PropertyInfo[] props = typeof(T).GetProperties(); - IEnumerable actualNames = dr.GetColumnSchema().Select(o => o.ColumnName); - for (int i = 0; i < props.Length; ++i) - { - PropertyInfo pi = props[i]; - - if (!pi.CanWrite) - { - continue; - } - - ColumnAttribute ca = pi.GetCustomAttribute(typeof(ColumnAttribute)) as ColumnAttribute; - string name = ca?.Name ?? pi.Name; - - if (pi == null) - { - continue; - } - - if (!actualNames.Contains(name)) - { - continue; - } - - object value = dr[name]; - Type pt = pi.DeclaringType; - bool nullable = pt.GetTypeInfo().IsGenericType && pt.GetGenericTypeDefinition() == typeof(Nullable<>); - if (value == DBNull.Value) - { - value = null; - } - - if (value == null && pt.GetTypeInfo().IsValueType && !nullable) - { - value = Activator.CreateInstance(pt); - } - - pi.SetValue(t, value); - } - - list.Add(t); - } - else - { - t = (T)Convert.ChangeType(dr[0], typeof(T), CultureInfo.InvariantCulture); - list.Add(t); - } - } - - return list; - } - - private static async Task ExecuteSqlQueryAsync( - this DbContext dbContext, - string sql, - IEnumerable parameters, - CancellationToken cancellationToken = default) - { - if (dbContext == null) - { - throw new ArgumentNullException(nameof(dbContext)); - } - - if (string.IsNullOrWhiteSpace(sql)) - { - throw new ArgumentNullException(nameof(sql)); - } - - IConcurrencyDetector concurrencyDetector = dbContext.GetService(); - - using (concurrencyDetector.EnterCriticalSection()) - { - RawSqlCommand rawSqlCommand = dbContext - .GetService() - .Build(sql, parameters); - - RelationalCommandParameterObject paramObject = new RelationalCommandParameterObject( - dbContext.GetService(), - rawSqlCommand.ParameterValues, - null, - null, - null); - - RelationalDataReader relationalDataReader = await rawSqlCommand - .RelationalCommand - .ExecuteReaderAsync(paramObject, cancellationToken); - - return relationalDataReader; - } - } } } diff --git a/src/TanvirArjel.EFCore.QueryRepository/TanvirArjel.EFCore.QueryRepository.csproj b/src/TanvirArjel.EFCore.QueryRepository/TanvirArjel.EFCore.QueryRepository.csproj index 16be83e..7f45af9 100644 --- a/src/TanvirArjel.EFCore.QueryRepository/TanvirArjel.EFCore.QueryRepository.csproj +++ b/src/TanvirArjel.EFCore.QueryRepository/TanvirArjel.EFCore.QueryRepository.csproj @@ -39,9 +39,9 @@ Git EFCore, RepositoryLayer, GenericRepository, QueryRepository, .NET, .NETCore, ASP.NETCore - 1. Multiple DbConext support has been added. + 1. SQL connection closing isssue has been fixed. - 1.3.0 + 1.4.0 LICENSE icon.png TanvirArjel