EqualNullable() public static method

public static EqualNullable ( Expression e1, Expression e2 ) : Expression
e1 System.Linq.Expressions.Expression
e2 System.Linq.Expressions.Expression
return System.Linq.Expressions.Expression
Beispiel #1
0
        private static Expression EnumEquals(Expression exp1, Expression exp2)
        {
            var exp1Clean = RemoveConvertChain(exp1);
            var exp2Clean = RemoveConvertChain(exp2);


            if (exp1 != exp1Clean || exp2 != exp2Clean)
            {
                var type = exp2.Type.IsNullable() ? exp1.Type.Nullify(): exp1.Type;


                return(SmartEqualizer.EqualNullable(exp1Clean.TryConvert(type), exp2Clean.TryConvert(type)));
            }

            return(null);
        }
Beispiel #2
0
        private static Expression EnumEquals(Expression exp1, Expression exp2)
        {
            var exp1Clean = RemoveConvertChain(exp1);
            var exp2Clean = RemoveConvertChain(exp2);

            if (exp1Clean.Type.UnNullify() == typeof(DayOfWeek) ||
                exp2Clean.Type.UnNullify() == typeof(DayOfWeek))
            {
                return(SmartEqualizer.EqualNullable(
                           ConstantToDayOfWeek(exp1Clean) ?? exp1Clean,
                           ConstantToDayOfWeek(exp2Clean) ?? exp2Clean));
            }

            if (exp1 != exp1Clean || exp2 != exp2Clean)
            {
                var type = exp2.Type.IsNullable() ? exp1.Type.Nullify(): exp1.Type;

                return(SmartEqualizer.EqualNullable(exp1Clean.TryConvert(type), exp2Clean.TryConvert(type)));
            }

            return(null);
        }