0
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' 型の定数値を作成できません。このコンテキストでは、プリミティブ型または列挙型のみがサポートされています。

このエラーを解決するにはどうすればよいですか? よろしくお願いします。

4

0 に答える 0