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

TypeUsageEquals() private static method

private static TypeUsageEquals ( TypeUsage left, TypeUsage right ) : bool
left TypeUsage
right TypeUsage
return bool
        private static bool TypeUsageEquals(TypeUsage left, TypeUsage right)
        {
            DebugCheck.NotNull(left);
            DebugCheck.NotNull(right);
            if (left.EdmType.EdmEquals(right.EdmType))
            {
                return true;
            }

            // compare element types for collection
            if (BuiltInTypeKind.CollectionType == left.EdmType.BuiltInTypeKind
                &&
                BuiltInTypeKind.CollectionType == right.EdmType.BuiltInTypeKind)
            {
                return TypeUsageEquals(
                    ((CollectionType)left.EdmType).TypeUsage,
                    ((CollectionType)right.EdmType).TypeUsage);
            }

            // special case for primitive types
            if (BuiltInTypeKind.PrimitiveType == left.EdmType.BuiltInTypeKind
                &&
                BuiltInTypeKind.PrimitiveType == right.EdmType.BuiltInTypeKind)
            {
                // since LINQ expressions cannot indicate model types directly, we must
                // consider types equivalent if they match on the given CLR equivalent
                // types (consider the Xml and String primitive types)
                return ((PrimitiveType)left.EdmType).ClrEquivalentType.Equals(
                    ((PrimitiveType)right.EdmType).ClrEquivalentType);
            }

            return false;
        }