public CodeMemberMethod GenerateMethod()
 {
     if (this.codeProvider == null)
     {
         throw new ArgumentException("codeProvider");
     }
     if (this.methodSource == null)
     {
         throw new ArgumentException("MethodSource");
     }
     QueryGeneratorBase base2 = null;
     if ((this.methodSource.QueryType == QueryType.Rowset) && (this.methodSource.CommandOperation == CommandOperation.Select))
     {
         base2 = new QueryGenerator(null) {
             ContainerParameterTypeName = this.GetParameterTypeName(),
             ContainerParameterName = this.GetParameterName(),
             ContainerParameterType = this.containerParameterType
         };
     }
     else
     {
         base2 = new FunctionGenerator(null);
     }
     base2.DeclarationOnly = true;
     base2.CodeProvider = this.codeProvider;
     base2.MethodSource = this.methodSource;
     base2.MethodName = this.GetMethodName();
     base2.ParameterOption = this.parameterOption;
     base2.GeneratePagingMethod = this.pagingMethod;
     base2.GenerateGetMethod = this.getMethod;
     return base2.Generate();
 }
 private void AddFunctionToDataComponent(CodeTypeDeclaration classDeclaration, DbSource dbSource, int commandIndex, bool isFunctionsDataComponent)
 {
     FunctionGenerator generator;
     if (!this.DeclarationsOnly || (dbSource.Modifier == MemberAttributes.Public))
     {
         generator = new FunctionGenerator(this.codeGenerator) {
             DeclarationOnly = this.declarationsOnly,
             MethodSource = dbSource,
             CommandIndex = commandIndex,
             DesignTable = this.designTable,
             IsFunctionsDataComponent = isFunctionsDataComponent
         };
         if (generator.MethodSource.Connection != null)
         {
             generator.ProviderFactory = ProviderManager.GetFactory(generator.MethodSource.Connection.Provider);
             goto Label_00A5;
         }
         if (this.designTable.Connection != null)
         {
             generator.ProviderFactory = ProviderManager.GetFactory(this.designTable.Connection.Provider);
             goto Label_00A5;
         }
     }
     return;
 Label_00A5:
     generator.MethodName = dbSource.GeneratorSourceName;
     generator.ParameterOption = this.languageSupportsNullables ? ParameterGenerationOption.ClrTypes : ParameterGenerationOption.Objects;
     CodeMemberMethod method = generator.Generate();
     if (method != null)
     {
         classDeclaration.Members.Add(method);
     }
 }
Example #3
0
        private void AddFunctionToDataComponent(CodeTypeDeclaration classDeclaration, DbSource dbSource, int commandIndex, bool isFunctionsDataComponent)
        {
            FunctionGenerator generator;

            if (!this.DeclarationsOnly || (dbSource.Modifier == MemberAttributes.Public))
            {
                generator = new FunctionGenerator(this.codeGenerator)
                {
                    DeclarationOnly          = this.declarationsOnly,
                    MethodSource             = dbSource,
                    CommandIndex             = commandIndex,
                    DesignTable              = this.designTable,
                    IsFunctionsDataComponent = isFunctionsDataComponent
                };
                if (generator.MethodSource.Connection != null)
                {
                    generator.ProviderFactory = ProviderManager.GetFactory(generator.MethodSource.Connection.Provider);
                    goto Label_00A5;
                }
                if (this.designTable.Connection != null)
                {
                    generator.ProviderFactory = ProviderManager.GetFactory(this.designTable.Connection.Provider);
                    goto Label_00A5;
                }
            }
            return;

Label_00A5:
            generator.MethodName      = dbSource.GeneratorSourceName;
            generator.ParameterOption = this.languageSupportsNullables ? ParameterGenerationOption.ClrTypes : ParameterGenerationOption.Objects;
            CodeMemberMethod method = generator.Generate();

            if (method != null)
            {
                classDeclaration.Members.Add(method);
            }
        }
Example #4
0
        public CodeMemberMethod GenerateMethod()
        {
            if (this.codeProvider == null)
            {
                throw new ArgumentException("codeProvider");
            }

            if (this.methodSource == null)
            {
                throw new ArgumentException("MethodSource");
            }

            QueryGeneratorBase queryGeneratorBase = null;

            if (this.methodSource.QueryType == QueryType.Rowset && this.methodSource.CommandOperation == CommandOperation.Select)
            {
                queryGeneratorBase = new QueryGenerator(null);
                queryGeneratorBase.ContainerParameterTypeName = this.GetParameterTypeName();
                queryGeneratorBase.ContainerParameterName     = this.GetParameterName();
                queryGeneratorBase.ContainerParameterType     = this.containerParameterType;
            }
            else
            {
                queryGeneratorBase = new FunctionGenerator(null);
            }

            queryGeneratorBase.DeclarationOnly      = true;
            queryGeneratorBase.CodeProvider         = this.codeProvider;
            queryGeneratorBase.MethodSource         = this.methodSource;
            queryGeneratorBase.MethodName           = this.GetMethodName();
            queryGeneratorBase.ParameterOption      = this.parameterOption;
            queryGeneratorBase.GeneratePagingMethod = this.pagingMethod;
            queryGeneratorBase.GenerateGetMethod    = this.getMethod;

            return(queryGeneratorBase.Generate());
        }