Fix caching work
This commit is contained in:
@@ -10,6 +10,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
|
|||||||
using HotAvalonia;
|
using HotAvalonia;
|
||||||
using Bitvault.Data;
|
using Bitvault.Data;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Bitvault.Avalonia;
|
namespace Bitvault.Avalonia;
|
||||||
|
|
||||||
@@ -42,7 +43,8 @@ public partial class App : Application
|
|||||||
{
|
{
|
||||||
args.AddServices(services =>
|
args.AddServices(services =>
|
||||||
{
|
{
|
||||||
services.AddTransient<IComparer<Item>>(provider => Comparer<Item>.Create((x, z) => x.Name.CompareTo(z.Name)));
|
services.AddTransient<IComparer<Item>>(provider => Comparer<Item>.Create((x, z) =>
|
||||||
|
StringComparer.CurrentCultureIgnoreCase.Compare(x.Name, z.Name)));
|
||||||
|
|
||||||
services.AddCache<Item>();
|
services.AddCache<Item>();
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,5 @@ public class AggerateContainerViewModelHandler(IMediator mediator,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var d = cache;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbConte
|
|||||||
public async Task<IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>> Handle(RequestEventArgs<QueryContainerConfiguration> args,
|
public async Task<IReadOnlyCollection<(Guid Id, string? Name, bool Favourite, bool Archived)>> Handle(RequestEventArgs<QueryContainerConfiguration> args,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
List<(Guid Id, string Name, bool Favourite, bool Archived)> items = [];
|
List<(Guid Id, string? Name, bool Favourite, bool Archived)> items = [];
|
||||||
|
|
||||||
if (args.Value is QueryContainerConfiguration queryConfiguration)
|
if (args.Value is QueryContainerConfiguration queryConfiguration)
|
||||||
{
|
{
|
||||||
@@ -41,16 +41,18 @@ public class QueryContainerHandler(IDbContextFactory<ContainerDbContext> dbConte
|
|||||||
var results = await Task.Run(async () =>
|
var results = await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
using ContainerDbContext context = dbContextFactory.CreateDbContext();
|
using ContainerDbContext context = dbContextFactory.CreateDbContext();
|
||||||
return await context.Set<ItemEntry>().Where(predicate).Select(x => new
|
return await context.Set<ItemEntry>()
|
||||||
|
.Where(predicate)
|
||||||
|
.Select(x => new
|
||||||
{
|
{
|
||||||
x.Id,
|
x.Id,
|
||||||
x.Name,
|
x.Name,
|
||||||
Favourite = x.State == 1,
|
Favourite = x.State == 1,
|
||||||
Archived = x.State == 2
|
Archived = x.State == 2
|
||||||
}).OrderBy(x => x.Name).ToListAsync();
|
}).ToListAsync();
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var result in results)
|
foreach (var result in results.OrderBy(x => x.Name, StringComparer.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
items.Add(new(result.Id, result.Name, result.Favourite, result.Archived));
|
items.Add(new(result.Id, result.Name, result.Favourite, result.Archived));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user