我正在制作一个搜索成员的函数,我想在我的 searchResults 变量中添加一个 Where。但是,在我这样做之前,它可能需要是一个 IQueryable。
这就是我想要完成的:
var searchResults = listMembers.DataSource = members.getAllMembers().OrderByDescending(x => x.createdDate).Select(x => new
{
x.ID,
x.memberNumber,
x.name,
x.email,
x.birthDate,
hasPayed = Helper.renderBoolImage(x.hasPayed, true),
isConfirmed = Helper.renderBoolImage(x.isConfirmed, true),
isExportedToExcel = Helper.renderBoolImage(x.isExportedToExcel, true)
});
if (!String.IsNullOrEmpty(search.name))
{
searchResults = searchResults.Where(x => x.name.ToLower().Equals(enc(search.name.ToLower())));
}
此行无法编译,因为它无法解析 Where:
searchResults = searchResults.Where(x => x.name.ToLower().Equals(enc(search.name.ToLower())));