///查询数据库的仓储类 ItestRepository test = new TestRepository(); ParameterExpression parameterExpression = Expression.Parameter(typeof(Test), "d"); PropertyInfo IdProp = typeof(Test).GetProperty("Id"); MemberExpression IdPropExp = Expression.Property(parameterExpression, IdProp); MethodInfo equals = typeof(int).GetMethod("Equals", new Type[1]{ typeof(int) }); ConstantExpression constant = Expression.Constant(1); var tt = Expression.Call(IdPropExp, equals, constant); Expression<Func<Test, bool>> pre = Expression.Lambda<Func<Test, bool>>( tt, new ParameterExpression[1] { parameterExpression } ); var where = pre.Compile(); var end = test.FindAll(where);