as no tracking get methods
This commit is contained in:
parent
0ee41aebef
commit
8790e7c7cf
6 changed files with 27 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ namespace SurveyLib.Core.Repositories;
|
||||||
public interface IGenericRepository<T> where T : class
|
public interface IGenericRepository<T> where T : class
|
||||||
{
|
{
|
||||||
Task<T?> GetByIdAsync(int id);
|
Task<T?> GetByIdAsync(int id);
|
||||||
|
Task<T?> GetByIdAsNoTrackingAsync(int id);
|
||||||
Task<IEnumerable<T>> GetAllAsync();
|
Task<IEnumerable<T>> GetAllAsync();
|
||||||
Task AddAsync(T entity);
|
Task AddAsync(T entity);
|
||||||
Task UpdateAsync(T entity);
|
Task UpdateAsync(T entity);
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@ public class AnswerRepository : IAnswerRepository
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<Answer?> GetByIdAsNoTrackingAsync(int id)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<Answer>> GetAllAsync()
|
public async Task<IEnumerable<Answer>> GetAllAsync()
|
||||||
{
|
{
|
||||||
return await _context.Answers.ToListAsync();
|
return await _context.Answers.ToListAsync();
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@ public class AnswerVariantsRepository : IAnswerVariantsRepository
|
||||||
return await _context.AnswerVariants.FindAsync(id);
|
return await _context.AnswerVariants.FindAsync(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<AnswerVariant?> GetByIdAsNoTrackingAsync(int id)
|
||||||
|
{
|
||||||
|
return await _context.AnswerVariants.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<AnswerVariant>> GetAllAsync()
|
public async Task<IEnumerable<AnswerVariant>> GetAllAsync()
|
||||||
{
|
{
|
||||||
return await _context.AnswerVariants.ToListAsync();
|
return await _context.AnswerVariants.ToListAsync();
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@ public class CompletionRepository : ICompletionRepository
|
||||||
return await _context.Completions.Include(c => c.Answers).FirstOrDefaultAsync(c => c.Id == id);
|
return await _context.Completions.Include(c => c.Answers).FirstOrDefaultAsync(c => c.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<Completion?> GetByIdAsNoTrackingAsync(int id)
|
||||||
|
{
|
||||||
|
return await _context.Completions.AsNoTracking().FirstOrDefaultAsync(c => c.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<Completion>> GetAllAsync()
|
public async Task<IEnumerable<Completion>> GetAllAsync()
|
||||||
{
|
{
|
||||||
return await _context.Completions.ToListAsync();
|
return await _context.Completions.ToListAsync();
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@ public class QuestionRepository : IQuestionRepository
|
||||||
return await _context.Questions.FindAsync(id);
|
return await _context.Questions.FindAsync(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<QuestionBase?> GetByIdAsNoTrackingAsync(int id)
|
||||||
|
{
|
||||||
|
return await _context.Questions.AsNoTracking().FirstOrDefaultAsync(x => x.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<QuestionBase>> GetAllAsync()
|
public async Task<IEnumerable<QuestionBase>> GetAllAsync()
|
||||||
{
|
{
|
||||||
return await _context.Questions.ToListAsync();
|
return await _context.Questions.ToListAsync();
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,11 @@ public class SurveyRepository : ISurveyRepository
|
||||||
return await _context.Surveys.FindAsync(id);
|
return await _context.Surveys.FindAsync(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<Survey?> GetByIdAsNoTrackingAsync(int id)
|
||||||
|
{
|
||||||
|
return await _context.Surveys.AsNoTracking().FirstOrDefaultAsync(c => c.Id == id);
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<Survey>> GetAllAsync()
|
public async Task<IEnumerable<Survey>> GetAllAsync()
|
||||||
{
|
{
|
||||||
return await _context.Surveys.ToListAsync();
|
return await _context.Surveys.ToListAsync();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue