I have one Linq expression and is executing properly by below code
Expression expressionMain=(Param_0.Email ?? "").StartsWith("[email protected]", OrdinalIgnoreCase)
var lambda = Expression.Lambda<Func<CustomModel, bool>>(expressionMain, paramExpr);
var compiledLambda = lambda.Compile();
var queryResult = TableEntity.AsQueryable()
.Where(compiledLambda)
.ToList();
but if i get that same expression as a string
"(Param_0.Email ?? "").StartsWith("[email protected]", OrdinalIgnoreCase)"
from some other source(sql), then how to convert/cast this to Expression and execute by above code?
UPDATES after checking the comments,I tried both links
Finally the Linq expression formart in both answer is differnt than mine.The expression will look like
{((Param_0.LocationId == Convert(46, Int32)) And (Param_0.DepartmentId == Convert(1, Nullable`1)))}
I am looking for a solution with this type of Expression