Exemple #1
0
        private FunctionReturnTypeInfo DetermineReturnType(FunctionData func)
        {
            var funcReturnTypeInfo = new FunctionReturnTypeInfo();

            var mappedReturnType = SqlHelper.MapDbTypeToType(func.ReturnType, null, false, false);

            if (mappedReturnType != null)
            {
                funcReturnTypeInfo.ElementType = mappedReturnType;

                if (func.IsMultiValueReturn)
                {
                    funcReturnTypeInfo.CollectionType = typeof(IEnumerable <>).MakeGenericType(mappedReturnType);
                }
            }

            if (mappedReturnType == null)
            {
                var userTypeName = cxInfo.GetTypeName(func.ReturnType);

                // ToDo | add schema support for functions
                mappedReturnType = moduleBuilder.GetType($"{nameSpace}.public.{userTypeName}");

                if (mappedReturnType != null)
                {
                    funcReturnTypeInfo.ExistsAsTable  = true;
                    funcReturnTypeInfo.ElementType    = mappedReturnType;
                    funcReturnTypeInfo.CollectionType = typeof(ITable <>).MakeGenericType(mappedReturnType);
                }
            }

            if (mappedReturnType == null)
            {
                mappedReturnType = typeof(ExpandoObject);
                funcReturnTypeInfo.ElementType    = mappedReturnType;
                funcReturnTypeInfo.CollectionType = typeof(IEnumerable <>).MakeGenericType(mappedReturnType);
            }

            return(funcReturnTypeInfo);
        }
      private FunctionReturnTypeInfo DetermineReturnType(FunctionData func)
      {
         var funcReturnTypeInfo = new FunctionReturnTypeInfo();

         var mappedReturnType = SqlHelper.MapDbTypeToType(func.ReturnType, null, false, false);

         if (mappedReturnType != null)
         {
            funcReturnTypeInfo.ElementType = mappedReturnType;

            if (func.IsMultiValueReturn)
            {
               funcReturnTypeInfo.CollectionType = typeof(IEnumerable<>).MakeGenericType(mappedReturnType);
            }
         }

         if (mappedReturnType == null)
         {
            var userTypeName = cxInfo.GetTypeName(func.ReturnType);
            mappedReturnType = moduleBuilder.GetType($"{nameSpace}.{userTypeName}");

            if (mappedReturnType != null)
            {
               funcReturnTypeInfo.ExistsAsTable = true;
               funcReturnTypeInfo.ElementType = mappedReturnType;
               funcReturnTypeInfo.CollectionType = typeof(ITable<>).MakeGenericType(mappedReturnType);
            }
         }

         if (mappedReturnType == null)
         {
            mappedReturnType = typeof(ExpandoObject);
            funcReturnTypeInfo.ElementType = mappedReturnType;
            funcReturnTypeInfo.CollectionType = typeof(IEnumerable<>).MakeGenericType(mappedReturnType);
         }

         return funcReturnTypeInfo;
      }