System.Data.Entity.Core.Objects.ELinq.ExpressionConverter.CreateEqualsExpression C# (CSharp) Method

CreateEqualsExpression() private method

Creates an implementation of equals using the given pattern. Throws exception when argument types are not supported for equals comparison.
private CreateEqualsExpression ( DbExpression left, DbExpression right, EqualsPattern pattern, Type leftClrType, Type rightClrType ) : DbExpression
left DbExpression
right DbExpression
pattern EqualsPattern
leftClrType Type
rightClrType Type
return DbExpression
        private DbExpression CreateEqualsExpression(
            DbExpression left, DbExpression right, EqualsPattern pattern, Type leftClrType, Type rightClrType)
        {
            VerifyTypeSupportedForComparison(leftClrType, left.ResultType, null, false);
            VerifyTypeSupportedForComparison(rightClrType, right.ResultType, null, false);

            //For Ref Type comparison, check whether they refer to compatible Entity Types.
            var leftType = left.ResultType;
            var rightType = right.ResultType;
            if (leftType.EdmType.BuiltInTypeKind == BuiltInTypeKind.RefType
                && rightType.EdmType.BuiltInTypeKind == BuiltInTypeKind.RefType)
            {
                TypeUsage commonType;
                if (!TypeSemantics.TryGetCommonType(leftType, rightType, out commonType))
                {
                    var leftRefType = left.ResultType.EdmType as RefType;
                    var rightRefType = right.ResultType.EdmType as RefType;
                    throw new NotSupportedException(
                        Strings.ELinq_UnsupportedRefComparison(leftRefType.ElementType.FullName, rightRefType.ElementType.FullName));
                }
            }

            return RecursivelyRewriteEqualsExpression(left, right, pattern);
        }