Currently, I have this method to compare two numbers
Private Function ETForGreaterThan(ByVal query As IQueryable(Of T), ByVal propertyValue As Object, ByVal
using System;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
namespace WindowsFormsApplication1
{
static class Program
{
[STAThread]
static void Main()
{
using (var context = new NorthwindEntities())
{
PropertyInfo propertyInfo = typeof(Customer).GetProperty("CustomerID");
IQueryable query = context.Customers;
query = ETForStartsWith(query, "A", propertyInfo);
var list = query.ToList();
}
}
static IQueryable ETForStartsWith(IQueryable query, string propertyValue, PropertyInfo propertyInfo)
{
ParameterExpression e = Expression.Parameter(typeof(T), "e");
MemberExpression m = Expression.MakeMemberAccess(e, propertyInfo);
ConstantExpression c = Expression.Constant(propertyValue, typeof(string));
MethodInfo mi = typeof(string).GetMethod("StartsWith", new Type[] { typeof(string) });
Expression call = Expression.Call(m, mi, c);
Expression> lambda = Expression.Lambda>(call, e);
return query.Where(lambda);
}
}
}