❔ Is saving data from DB into private fields is a good idea?

Lets say i have this class:
  public class LessonAppService :ApplicationService,
    ILessonService //implement the IBookAppService
    {
      
        private List<Lesson> _UserLessons;
}


And this method:
   public async Task<List<LessonDTO>> GetUserLessons()
           
        {
            var queryable = await _lessonRepository.WithDetailsAsync();
            var lessonsQuery= queryable.Where(x=>x.CreatorId == CurrentUser.Id).OrderBy(x=>x.LessonNumber).Take(20);
            var lessons = await lessonsQuery.ToListAsync();
            _UserLessons = lessons;
            return ObjectMapper.Map<List<Lesson>, List<LessonDTO>>(lessons);
            
        }


Would it be good to operate on that private field of entites instead of making additional DB calls?
Same for example :
        private Lesson _activeLesson;

Any ideas?
Was this page helpful?