Update gestione vocabolario con FusionCache
This commit is contained in:
@@ -2627,21 +2627,36 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Vocabolario (completo)
|
||||
/// Elenco Vocabolario di una lingua
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<VocabolarioModel> VocabolarioGetAll()
|
||||
public Dictionary<string, string> VocabolarioGetLang(string lingua)
|
||||
{
|
||||
List<VocabolarioModel> dbResult = new List<VocabolarioModel>();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
var rawList = dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
.Where(x => x.Lingua.ToLower() == lingua.ToLower())
|
||||
.OrderBy(x => x.Lemma)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
// Proietto in dizionario
|
||||
return rawList
|
||||
.DistinctBy(t => t.Lemma, StringComparer.OrdinalIgnoreCase)
|
||||
.ToDictionary(t => t.Lemma, t => t.Traduzione, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Vocabolario (completo) async
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<VocabolarioModel>> VocabolarioGetAllAsync()
|
||||
{
|
||||
using var dbCtx = new MoonProContext(options);
|
||||
return await dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Lemma)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user