Hi Richard,
Thank you so much for your help.
The code which you gave that works fine with Constant which comes at the right side of the operator.
I have List<Report> lstReport=New List<Report>();
I want to write lstReport=lstReport.Where(o=>DateTime.Parse(o.Field)==DateTime.Parse(o.FieldValue));
I am creating above statement dynamically
like this
var variable = Expression.Variable(typeof(Report));
foreach (SQWFilterConstraint oFC in oFilter.LstFilterConstraint) //usingthis collection I am making dynamic query
{
Expression ExprLeft =Expression.Property(variable, oFC.Field);
MethodInfo methodDateTimeParse = typeof(DateTime).GetMethod("Parse", newType[] { typeof(string) });
var methodParam = Expression.Parameter(typeof(string), oFC.FieldValue);
Expression exprRight = Expression.Call(methodDateTimeParse, methodParam );
}
var props = new[] { variable };
var lambda = Expression.Lambda<Func<Report, bool>>(ExprPrev, props).Compile();
ReportList = ReportList.Where(lambda).ToList();
So Need to apply DateTime.Parse method on filed also which comes at the left side of the operator
I will be very thank full if you provide help.
Thanks in Advance