Home > Net >  This extension, how to change? thank you
This extension, how to change? thank you

Time:01-15

The following code compilation is not through,,



 
///& lt; Summary>
///according to the specified attribute name
sorting sequence///& lt;/summary>
///& lt; Typeparam name="T" & gt; The type of the elements in the source & lt;/typeparam>
///& lt; Param name="source" & gt; To sort the values of the sequence & lt;/param>
///& lt; Param name="property" & gt; The attribute name & lt;/param>
///& lt; Param name="item first-just & gt;" Whether descending & lt;/param>
///& lt; Returns>
Public static IEnumerable OrderBy (this IEnumerable The source, the string property, bool item first-just) where T: class
{
ParameterExpression param=Expression. The Parameter (typeof (T), "c");
PropertyInfo PI=typeof (T). GetProperty (property);
MemberExpression selector=Expression. MakeMemberAccess (param, PI);
LambdaExpression le=Expression. Lambda (selector, param);
String methodName=(item first-just)? "OrderByDescending" : the "OrderBy";
MethodCallExpression resultExp=Expression. The Call (typeof (Queryable), methodName, new Type [] {typeof (T), PI, PropertyType}, source, Expression, le);
Return to the source. The Provider. CreateQuery (resultExp);
}

CodePudding user response:

IEnumerable
?????????????????????????

Since to do expression, please use the IQueryable not IEnumerable
  • Related