次のようなクエリ式の式ツリーを作成したいと思います: employee => employee.Salary.StartsWith("28")
そのため、SQL は次のように表示されます。 where (employee.salary like '28%')
問題は、従業員オブジェクトの Salary プロパティが小数であり、StartsWith が小数のプロパティではないことです。どうすればこれを行うことができますか。
私の誤った式ツリーの構文は次のとおりです。
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 });