'How to use Search functionality in mvc controller with searchstring

I am trying to implement search functionality in controller method but I got as i am not able to use "Get" clause, it throws and type conversion error. I get error at

getAll = getAll.Content.Where(a => a.Firstname.Contains(searchString) || a.Lastname.Contains(searchString));

.controller method

[HttpGet]
    public async Task<IActionResult> Index(UserViewModel userVM)
    {
        
        var userData = await _userSessionCache.GetUserSessionWithUserIdAsync();
        var tenantClientId = userData.TenantClientId;
        var getAll = await _userApiService.GetAll(tenantClientId);
        var searchString = userVM.SearchString;
        if(!string.IsNullOrEmpty(searchString))
        {
            getAll = getAll.Content.Where(a => a.Firstname.Contains(searchString) || a.Lastname.Contains(searchString));
        }
        if (!getAll.IsSuccessful)
        {
            throw new System.Exception("Unable to get User Data");
        }

        var dataList = getAll.Content;
        var vm = new UserViewModel();
        vm.SetUser(dataList);
        return View(vm);
    }

.cs

Task<ApiResponse<List>> GetAll(Guid tenantClientId);



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source