How to extract properties used in a Expression<Func<T, TResult>> query and test their value?
问题 I need to create a function to evaluate queries for some rules before executing them. Here's the code: public class DataInfo { public int A { get; set; } public int B { get; set; } public int C { get; set; } } static class Program { static void Main() { var data = new DataInfo() { A = 10, B = 5, C = -1 }; // the result should be -1 int result = Calcul<DataInfo>(data, x => x.A / x.B + x.C); } static int Calcul<T>(T data, Expression<Func<T, int>> query) { // PSEUDO CODE // if one property used