public static Expression PolymorphicEqual(Expression exp1, Expression exp2) { if (exp1.NodeType == ExpressionType.New && exp2.NodeType == ExpressionType.New) { return((exp1 as NewExpression).Arguments.ZipStrict( (exp2 as NewExpression).Arguments, (o, i) => SmartEqualizer.PolymorphicEqual(o, i)).AggregateAnd()); } Expression result; result = PrimaryKeyEquals(exp1, exp2); if (result != null) { return(result); } result = ObjectEquals(exp1, exp2); if (result != null) { return(result); } result = ConditionalEquals(exp1, exp2); if (result != null) { return(result); } result = CoalesceEquals(exp1, exp2); if (result != null) { return(result); } result = LiteEquals(exp1, exp2); if (result != null) { return(result); } result = EntityEquals(exp1, exp2); if (result != null) { return(result); } result = TypeEquals(exp1, exp2); if (result != null) { return(result); } result = MListElementEquals(exp1, exp2); if (result != null) { return(result); } return(EqualNullable(exp1, exp2)); }
public static Expression PolymorphicEqual(Expression exp1, Expression exp2) { if (exp1.NodeType == ExpressionType.New || exp2.NodeType == ExpressionType.New) { if (exp1.IsNull() || exp2.IsNull()) { return(Expression.Constant(false)); } exp1 = ConstanToNewExpression(exp1) ?? exp1; exp2 = ConstanToNewExpression(exp2) ?? exp2; return(((NewExpression)exp1).Arguments.ZipStrict( ((NewExpression)exp2).Arguments, (o, i) => SmartEqualizer.PolymorphicEqual(o, i)).AggregateAnd()); } Expression?result; result = PrimaryKeyEquals(exp1, exp2); if (result != null) { return(result); } result = ObjectEquals(exp1, exp2); if (result != null) { return(result); } result = ConditionalEquals(exp1, exp2); if (result != null) { return(result); } result = CoalesceEquals(exp1, exp2); if (result != null) { return(result); } result = LiteEquals(exp1, exp2); if (result != null) { return(result); } result = EntityEquals(exp1, exp2); if (result != null) { return(result); } result = TypeEquals(exp1, exp2); if (result != null) { return(result); } result = MListElementEquals(exp1, exp2); if (result != null) { return(result); } result = EnumEquals(exp1, exp2); if (result != null) { return(result); } return(EqualNullable(exp1, exp2)); }