var parameterExpression = Expression.Parameter(typeof(Students), "st");
var memberExpression = Expression.Property(parameterExpression, typeof(Students).GetProperty("StudentName"));
Expression conversion = Expression.Convert(memberExpression, typeof(object));//此步骤解决Expression of type 'System.Nullable`1[System.Int32]' cannot be used for return type 'System.Object'
Expression<Func<Students, object>> orderbyExpression = Expression.Lambda<Func<Students, object>>(conversion, parameterExpression);
引用命名空间 System.Linq.Expressions
Students为实体类
StudentName为排序列
转换后为 st=>st.StudentName
应用场景:ORM框架查询,可以利用Lamda表达式防止注入,原为字符串组合方式存在注入风险