64 lines
1.8 KiB
C#
64 lines
1.8 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using MP.Data.DbModels;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace MP.Data.Repository.MpVoc
|
|
{
|
|
public class MpVocRepository : IMpVocRepository
|
|
{
|
|
#region Private Fields
|
|
|
|
private readonly IDbContextFactory<MoonPro_VocContext> _ctxFactory;
|
|
|
|
#endregion
|
|
|
|
#region Public Constructors
|
|
|
|
public MpVocRepository(IDbContextFactory<MoonPro_VocContext> ctxFactory)
|
|
{
|
|
_ctxFactory = ctxFactory;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Public Methods
|
|
|
|
/// <inheritdoc />
|
|
public async Task<List<ConfigModel>> ConfigGetAllAsync()
|
|
{
|
|
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
|
return await dbCtx
|
|
.DbSetConfig
|
|
.AsNoTracking()
|
|
.OrderBy(x => x.Chiave)
|
|
.ToListAsync() ?? new();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task<List<LingueModel>> LingueGetAllAsync()
|
|
{
|
|
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
|
return await dbCtx
|
|
.DbSetLilngue
|
|
.AsNoTracking()
|
|
.OrderBy(x => x.Lingua)
|
|
.ToListAsync() ?? new();
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task<List<VocabolarioModel>> VocabolarioGetAllAsync()
|
|
{
|
|
await using var dbCtx = await _ctxFactory.CreateDbContextAsync();
|
|
return await dbCtx
|
|
.DbSetVocabolario
|
|
.AsNoTracking()
|
|
.OrderBy(x => x.Lemma)
|
|
.ToListAsync() ?? new();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|