我正在创建一个搜索页面,以便根据用户名,审批状态以及当前是否已将其锁定来过滤用户。
if (!string.IsNullOrEmpty(filterby))
{
int totalRecords;
if (filterby == "all")
{
viewModel.PaginatedUserList = Membership.GetAllUsers(page, pageSize, out totalRecords).ToPaginatedList(page, pageSize, totalRecords, searchterm, filterby);
}
else if (!string.IsNullOrEmpty(searchterm))
{
string query = searchterm + "%";
if (filterby == "email")
{
viewModel.PaginatedUserList = Membership.FindUsersByEmail(query, page, pageSize, out totalRecords).ToPaginatedList(page, pageSize, totalRecords, searchterm, filterby);
}
else if (filterby == "username")
{
viewModel.PaginatedUserList = Membership.FindUsersByName(query, page, pageSize, out totalRecords).ToPaginatedList(page, pageSize, totalRecords, searchterm, filterby);
}
else if (filterby == "approval")
{
viewModel.PaginatedUserList = (PaginatedList<MembershipUser>) Membership.GetAllUsers(page, pageSize, out totalRecords).ToPaginatedList(page, pageSize, totalRecords, searchterm, filterby).Where(x => x.IsApproved == false);
}
}
}
我得到“无法转换类型的对象'WhereListIterator 1[System.Web.Security.MembershipUser]' to type 'Project.Core.Pagination.PaginatedList
1 [System.Web.Security.MembershipUser]'。”每当我尝试通过批准搜索。由于我还在学习,我不太确定解决这个问题的最佳方法。任何帮助将不胜感激。