ARTICLE AD BOX
I have an IQueryable expression:
... Where(x => Convert.ToInt64(x.string_param) > Convert.ToInt64(string_const)) ...How to build this throught expression tree? Kind of:
var left = ...? var right = Expression.Constant(Convert.ToInt64(filter.From), typeof(Int64)); greaterExpression = Expression.GreaterThanOrEqual(left, right);This line of code:
var left = Expression.Convert(property, typeof(Int64))is not working, it throws an exception:
No coercion operator is defined between types 'System.String' and 'System.Int64'
This is the method signature:
public static Expression<Func<TQuery, bool>> GetFilterRange<TQuery>(FilterRange<string> filter) { var paramter = Expression.Parameter(typeof(TQuery)); var property = Expression.PropertyOrField(paramter, filter.PropertyName); ... return greaterExpression; }PS: string is nulable type in query string?
760k186 gold badges1.4k silver badges1.5k bronze badges
4
