Reputation: 3
The below line of code is giving an exception:
listEmpFullDetails = (List<EmployeeListVM>)listEmpFullDetails.Skip(start).Take(pageSize);
Exception received:
Unable to cast object of type 'd__251[ess.Model.Common.EmployeeListVM]' to type 'System.Collections.Generic.List1
Upvotes: 0
Views: 46
Reputation: 1312
You can't just cast this an iterator to a list. Instead, simply chain a .ToList()
at the end, so:
listEmpFullDetails = listEmpFullDetails
.Skip(start)
.Take(pageSize)
.ToList();
Upvotes: 2