I would like to create an expression tree for a query expression that looks something like this: employee => employee.Salary.StartsWith("28")
So that the sql could appear as: where (employee.salary like '28%')
The problem is that the property Salary of the employee object is a decimal and StartsWith is not a property of a decimal. How can i get around to do this.
My erroneous expression tree syntax is as follows:
var searchTextExp = Expression.Constant("28");
var parameterExp = Expression.Parameter(typeof(EmployeeEntity), "employee");
var propertyExp = Expression.Property(parameterExp, "Salary");
var startsWithExp = Expression.Call(propertyExp, "StartsWith", null,
searchTextExp);
Expression<Func<EmployeeEntity, bool>> searchExpr =
Expression.Lambda<Func<EmployeeEntity, bool>>
(startsWithExp, new ParameterExpression[] { parameterExp });