update to load the data in scope.

This commit is contained in:
Ben
2024-03-19 09:19:56 +08:00
parent 055e54966d
commit 0cafef7ab4
14 changed files with 46 additions and 58 deletions

View File

@ -8,17 +8,16 @@ namespace Oqtane.Repository
public class LanguageRepository : ILanguageRepository
{
private readonly IDbContextFactory<TenantDBContext> _dbContextFactory;
private readonly TenantDBContext _queryContext;
public LanguageRepository(IDbContextFactory<TenantDBContext> dbContextFactory)
{
_dbContextFactory = dbContextFactory;
_queryContext = _dbContextFactory.CreateDbContext();
}
public IEnumerable<Language> GetLanguages(int siteId)
{
return _queryContext.Language.Where(l => l.SiteId == siteId);
using var db = _dbContextFactory.CreateDbContext();
return db.Language.Where(l => l.SiteId == siteId).ToList();
}
public Language AddLanguage(Language language)