コード例 #1
0
        private static bool ValidateFunctionImportMappingResultTypeCompatibility(TypeUsage cSpaceMemberType, TypeUsage sSpaceMemberType)
        {
            // Function result data flows from S-side to C-side.
            var fromType = sSpaceMemberType;
            var toType   = ResolveTypeUsageForEnums(cSpaceMemberType);

            var directlyPromotable  = TypeSemantics.IsStructurallyEqualOrPromotableTo(fromType, toType);
            var inverselyPromotable = TypeSemantics.IsStructurallyEqualOrPromotableTo(toType, fromType);

            // We are quite lax here. We only require that values belong to the same class (can flow in one or the other direction).
            // We could require precisely s-type to be promotable to c-type, but in this case it won't be possible to reuse the same
            // c-types for mapped functions and entity sets, because entity sets (read-write) require c-types to be promotable to s-types.
            return(directlyPromotable || inverselyPromotable);
        }
コード例 #2
0
 private static void RequireCompatibleType(
     DbExpression expression,
     TypeUsage requiredResultType,
     string argumentName,
     int argumentIndex)
 {
     if (!TypeSemantics.IsStructurallyEqualOrPromotableTo(expression.ResultType, requiredResultType))
     {
         if (argumentIndex != -1)
         {
             argumentName = StringUtil.FormatIndex(argumentName, argumentIndex);
         }
         throw new ArgumentException(Strings.Cqt_ExpressionLink_TypeMismatch((object)expression.ResultType.ToString(), (object)requiredResultType.ToString()), argumentName);
     }
 }
コード例 #3
0
        private static bool ValidateFunctionImportMappingResultTypeCompatibility(
            TypeUsage cSpaceMemberType,
            TypeUsage sSpaceMemberType)
        {
            TypeUsage typeUsage1 = sSpaceMemberType;
            TypeUsage typeUsage2 = FunctionImportMappingComposableHelper.ResolveTypeUsageForEnums(cSpaceMemberType);
            bool      flag1      = TypeSemantics.IsStructurallyEqualOrPromotableTo(typeUsage1, typeUsage2);
            bool      flag2      = TypeSemantics.IsStructurallyEqualOrPromotableTo(typeUsage2, typeUsage1);

            if (!flag1)
            {
                return(flag2);
            }
            return(true);
        }
コード例 #4
0
        private static void RequireCompatibleType(
            DbExpression from,
            RelationshipEndMember end,
            bool allowAllRelationshipsInSameTypeHierarchy)
        {
            TypeUsage typeUsage = end.TypeUsage;

            if (!TypeSemantics.IsReferenceType(typeUsage))
            {
                typeUsage = TypeHelpers.CreateReferenceTypeUsage(TypeHelpers.GetEdmType <EntityType>(typeUsage));
            }
            if (allowAllRelationshipsInSameTypeHierarchy)
            {
                if (TypeHelpers.GetCommonTypeUsage(typeUsage, from.ResultType) == null)
                {
                    throw new ArgumentException(Strings.Cqt_RelNav_WrongSourceType((object)typeUsage.ToString()), nameof(from));
                }
            }
            else if (!TypeSemantics.IsStructurallyEqualOrPromotableTo(from.ResultType.EdmType, typeUsage.EdmType))
            {
                throw new ArgumentException(Strings.Cqt_RelNav_WrongSourceType((object)typeUsage.ToString()), nameof(from));
            }
        }