linq expression in vb.net
Posted
by Thurein
on Stack Overflow
See other posts from Stack Overflow
or by Thurein
Published on 2010-05-11T03:21:37Z
Indexed on
2010/05/11
3:24 UTC
Read the original article
Hit count: 307
LINQ
|lambda-expressions
Hi,
Can any body translate the following c# code to vb. I have tried telarik code converter but I got problem at expression.call and it won't compile at all.
private static IOrderedQueryable<T> OrderingHelper<T>(IQueryable<T> source, string propertyName, bool descending, bool anotherLevel)
{
ParameterExpression param = Expression.Parameter(typeof(T), string.Empty);
MemberExpression property = Expression.PropertyOrField(param, propertyName);
LambdaExpression sort = Expression.Lambda(property, param);
MethodCallExpression call = Expression.Call(
typeof(Queryable),
(!anotherLevel ? "OrderBy" : "ThenBy") + (descending ? "Descending" : string.Empty),
new[] { typeof(T), property.Type }, // error line
source.Expression,
Expression.Quote(sort));
return (IOrderedQueryable<T>)source.Provider.CreateQuery<T>(call);
}
thanks Thurein
© Stack Overflow or respective owner