mirror of
https://github.com/collinbarrett/FilterLists.git
synced 2026-03-11 09:04:27 +00:00
explicitly run SeedService.GetAllAsync() in-memory per ef core 3
https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-3.0/breaking-changes#linq-queries-are-no-longer-evaluated-on-the-client
This commit is contained in:
parent
f9d8ad0f09
commit
6dec350119
6 changed files with 16 additions and 11 deletions
|
|
@ -21,11 +21,11 @@
|
|||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.DotNet.Analyzers.Compatibility" Version="0.2.12-alpha" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.6">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.6" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="3.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -102,7 +102,7 @@ private static async Task InsertOnDuplicateKeyUpdate<TEntity>(DbContext dbContex
|
|||
return;
|
||||
var columns = string.Join(", ", properties.Select(x => x.Name));
|
||||
var updates = CreateUpdates(properties);
|
||||
var sql = "INSERT INTO " + entityType.Relational().TableName + " (" + columns + ") VALUES " + values +
|
||||
var sql = "INSERT INTO " + entityType.GetTableName() + " (" + columns + ") VALUES " + values +
|
||||
" ON DUPLICATE KEY UPDATE " + updates;
|
||||
await dbContext.Database.ExecuteSqlCommandAsync(sql);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@
|
|||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
|
||||
using Pomelo.EntityFrameworkCore.MySql.Storage;
|
||||
using System;
|
||||
|
||||
namespace FilterLists.Services.DependencyInjection.Extensions
|
||||
{
|
||||
|
|
@ -22,7 +25,8 @@ public static void AddFilterListsApiServices(this IServiceCollection services, I
|
|||
services.AddSingleton(c => config);
|
||||
services.AddDbContextPool<FilterListsDbContext>(o =>
|
||||
o.UseMySql(config.GetConnectionString("FilterListsConnection"),
|
||||
m => m.MigrationsAssembly("FilterLists.Api")));
|
||||
m => m.MigrationsAssembly("FilterLists.Api")
|
||||
.ServerVersion(new ServerVersion(new Version(10, 4, 12), ServerType.MariaDb))));
|
||||
services.TryAddScoped<FilterListService>();
|
||||
services.TryAddScoped<LanguageService>();
|
||||
services.TryAddScoped<LicenseService>();
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@ public async Task<IEnumerable<TSeedDto>> GetAllAsync<TEntity, TSeedDto>() where
|
|||
public async Task<IEnumerable<TSeedDto>> GetAllAsync<TEntity, TSeedDto>(PropertyInfo primarySort,
|
||||
PropertyInfo secondarySort)
|
||||
where TEntity : class =>
|
||||
await DbContext.Set<TEntity>()
|
||||
.OrderBy(s => primarySort.GetValue(s, null))
|
||||
.ThenBy(s => secondarySort.GetValue(s, null))
|
||||
.ProjectTo<TSeedDto>(MapConfig)
|
||||
.ToListAsync();
|
||||
(await DbContext.Set<TEntity>().ToListAsync())
|
||||
.AsQueryable()
|
||||
.OrderBy(s => primarySort.GetValue(s, null))
|
||||
.ThenBy(s => secondarySort.GetValue(s, null))
|
||||
.ProjectTo<TSeedDto>(MapConfig)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
|
@ -36,7 +36,7 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.6">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.6">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
|
|
|||
Loading…
Reference in a new issue