Currently I am using expression builder for dynamic query generation.
I have created dynamic expressions for int, date time, and string operators. Now I am stuck at one point .
I want to compare month part of datetime through expression.
We are passing property of datetime and want to create expression for month of that property.
Code:
public static Expression GetDynamicquery<TSource>(
string property, object value, ParameterExpression p)
{
var propertyReference = Expression.Property(p, property);
var constantReference = Expression.Constant(value);
var expression = Expression.Equal(propertyReference, constantReference);
MethodInfo method = null;
return Expression.LessThanOrEqual(propertyReference, constantReference);
}
Here property is name of property which I am passing into Tsource.
p
is parameter expression of type Tsource.
I want result like all birthdate of this month.