Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 使用枚举生成lessthanRequal表达式_C# 4.0 - Fatal编程技术网

C# 4.0 使用枚举生成lessthanRequal表达式

C# 4.0 使用枚举生成lessthanRequal表达式,c#-4.0,C# 4.0,我需要在运行时创建依赖于查询的表达式。Enums具有隐式运算符,似乎 public enum A { A1, A2, A3 }; public class AA { public A myA { get; set; } public int myB { get; set; } }; ParameterExpression pe = Expression.Parameter(typeof(AA), "p"); Expression.LessThanO

我需要在运行时创建依赖于查询的表达式。Enums具有隐式运算符,似乎

public enum A
{
    A1,
    A2,
    A3
};

public class AA
{
    public A myA { get; set; }
    public int myB { get; set; }
};

ParameterExpression pe = Expression.Parameter(typeof(AA), "p");

 Expression.LessThanOrEqual(Expression.Property(
                                  pe,
                                  typeof(AA).GetProperty("myA")),
                                  Expression.Constant(A.A1, typeof(A)));
Expression.LessThanOrEqual(Expression.Convert(Expression.Property(
    pe,
    typeof(AA).GetProperty("myA")), typeof(int)),
    Expression.Convert(Expression.Constant(A.A1, typeof(A)), typeof(int)));