title: ASP.NET Core Web API - How to resolve Error CS0103 The name 'score' does not exist in the current context
body: <p>In ASP.NET Core 6, I have this code.</p>
  <pre><code>public static class Paginator
  {
      public static async Task&lt;PageResult&lt;IEnumerable&lt;TDestination&gt;&gt;&gt; PaginationAsync&lt;TSource, TDestination&gt;(this IQueryable&lt;TSource&gt; querable, int pageSize, int pageNumber, IMapper mapper)
          where TSource : class
          where TDestination : class
      {
          var count = querable.Count();
          var pageResult = new PageResult&lt;IEnumerable&lt;TDestination&gt;&gt;
          {
              PageSize = (pageSize &gt; 10 || pageSize &lt; 1) ? 10 : pageSize,
              CurrentPage = pageNumber &gt; 1 ? pageNumber : 1,
              TotalRecord = count,
              PreviousPage = pageNumber &gt; 0 ? pageNumber - 1 : 0
          };
          pageResult.NumberOfPages = count % pageResult.PageSize != 0
                  ? count / pageResult.PageSize + 1
                  : count / pageResult.PageSize;
          var sourceList = await querable.Skip((pageResult.CurrentPage - 1) * pageResult.PageSize).Take(pageResult.PageSize).ToListAsync();
          var destinationList = mapper.Map&lt;IEnumerable&lt;TSource&gt;, IEnumerable&lt;TDestination&gt;&gt;(sourceList);
          pageResult.PageItems = destinationList;
          return pageResult;
      }
  }
  </code></pre>
  <p>Repository interface:</p>
  <pre><code>IQueryable&lt;Score&gt; GetExamScoreAsync(PagingFilter filter)
  </code></pre>
  <p>Repository implementation:</p>
  <pre><code>public IQueryable&lt;Score&gt; GetExamScoreAsync(PagingFilter filter)
  {
      var examScores = _dbContext.Scores
              .Where(m =&gt; (bool)m.Approval.IsFirstLevel == false)
              .Where(x =&gt; string.IsNullOrEmpty(filter.SearchQuery)
          || x.Subject.ToLower().Contains(filter.SearchQuery.ToLower())
          || x.StartDate.ToString(&quot;dd/MM/yyyy&quot;, CultureInfo.InvariantCulture).Contains(filter.SearchQuery.ToLower())
          || x.EndDate.ToString(&quot;dd/MM/yyyy&quot;, CultureInfo.InvariantCulture).Contains(filter.SearchQuery.ToLower()))
              .OrderByDescending(x =&gt; x.CreatedAt);
      return examScores;
  }
  </code></pre>
  <p>Then I called it it the service:</p>
  <pre><code>public async Task&lt;Response&lt;PageResult&lt;IEnumerable&lt;ScoreListDto&gt;&gt;&gt;&gt; GetScoreAsync(PagingFilter filter)
  {
      var userName = _currentUserService.UserName;
      var getUser = await _userManager.FindByNameAsync(userName);
      var loggedUserRole = await _userManager.GetRolesAsync(getUser);
      var loggedUserRoleName = loggedUserRole[0].ToString();
  
      if (loggedUserRoleName == &quot;Student&quot;)
      {
          var score = await _unitOfWork.ExamScore.GetExamScoreStudentAsync(filter);
      }
      else
      {
          var score = await _unitOfWork.ExamScore.GetExamScoreAsync(filter);
      }
          
      var item = await score.PaginationAsync&lt;Score, ScoreListDto&gt;(filter.PageSize, filter.PageNumber, _mapper);
  
      return new Response&lt;PageResult&lt;IEnumerable&lt;ScoreListDto&gt;&gt;&gt;()
      {
          StatusCode = (int)HttpStatusCode.OK,
          Successful = true,
          Data = item
      };
  }
  </code></pre>
  <p>I got this error:</p>
  <blockquote>
  <p>Error CS0103 The name 'score' does not exist in the current context</p>
  </blockquote>
  <p>Score is highlighted in:</p>
  <pre><code>var item = await score.PaginationAsync&lt;Score, ScoreListDto&gt;(filter.PageSize, filter.PageNumber, _mapper);
  </code></pre>
  <p>How do I resolve this?</p>
  <p>Thanks</p>