public static PaginationInfo<T> PageList<T, S>(this IQueryable<T> entity, string searchKeyword = "")
where T : class, new()
where S : class, new()
{
//...
var stringProperties = typeof(S).GetProperties()
.Where(prop => prop.PropertyType == searchKeyword.GetType());
var query = entity.Where(x => stringProperties.Any(prop => prop.GetValue(x, null) == searchKeyword)).ToList();
//...
}
当我编写如上所示的代码时,却出现错误:
<块引用>System.NotSupportedException:无法创建类型为“System.Reflection.PropertyInfo”的常量值。此上下文中仅支持原始类型或枚举类型。
我应该如何解决这个错误?预先感谢您的帮助。