public IQueryable<Users> SelectAdmin<TProp>(string sSortExpression, string sSortOrder ,long[] IAds, int iStart, int iEnd, long iId)
{
var param = Expression.Parameter(typeof(Users));
var propExpression = Expression.Lambda<Func<Users, TProp>>(Expression.Property(param, sSortExpression), param);
if (sSortOrder == "asc")
{
return objCouponUow.Repository<Users>().Entities.Where(x => x.UserGroup == 9 && x.Validate == 0 && x.Deleted == false && IAds.Contains(x.UserParent)).OrderBy(propExpression).Skip(iStart).Take(iEnd - iStart);
}
}
这是我的函数...我在这一行遇到了错误:
var propExpression = Expression.Lambda<Func<Users, TProp>>(Expression.Property(param, sSortExpression), param);
当' sSortExpression '是 Users 表中的列且为 Varchar 类型时,没有问题。但如果它是 Int 类型,则会出现错误。错误信息为“无法将类型为'System.Int16'的表达式用于返回类型'System.Object'”
我该如何解决这个问题?