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 AddMainQueriesToDataComponent(CodeTypeDeclaration classDeclaration) { if (this.designTable == null) { throw new InternalException("Design Table should not be null."); } if (this.designTable.MainSource != null) { QueryGenerator queryGenerator = new QueryGenerator(this.codeGenerator) { DeclarationOnly = this.declarationsOnly, MethodSource = this.designTable.MainSource as DbSource, CommandIndex = 0, DesignTable = this.designTable }; if (queryGenerator.MethodSource.Connection != null) { queryGenerator.ProviderFactory = ProviderManager.GetFactory(queryGenerator.MethodSource.Connection.Provider); } else if (this.designTable.Connection != null) { queryGenerator.ProviderFactory = ProviderManager.GetFactory(this.designTable.Connection.Provider); } else { return; } if ((queryGenerator.MethodSource.QueryType == QueryType.Rowset) && (queryGenerator.MethodSource.CommandOperation == CommandOperation.Select)) { if ((queryGenerator.MethodSource.GenerateMethods == GenerateMethodTypes.Fill) || (queryGenerator.MethodSource.GenerateMethods == GenerateMethodTypes.Both)) { queryGenerator.MethodName = this.designTable.MainSource.GeneratorSourceName; this.GenerateQueries(classDeclaration, queryGenerator); if (queryGenerator.MethodSource.GeneratePagingMethods) { queryGenerator.MethodName = this.designTable.MainSource.GeneratorSourceNameForPaging; queryGenerator.GeneratePagingMethod = true; this.GenerateQueries(classDeclaration, queryGenerator); queryGenerator.GeneratePagingMethod = false; } } if ((queryGenerator.MethodSource.GenerateMethods == GenerateMethodTypes.Get) || (queryGenerator.MethodSource.GenerateMethods == GenerateMethodTypes.Both)) { queryGenerator.GenerateGetMethod = true; queryGenerator.MethodName = this.designTable.MainSource.GeneratorGetMethodName; this.GenerateQueries(classDeclaration, queryGenerator); if (queryGenerator.MethodSource.GeneratePagingMethods) { queryGenerator.MethodName = this.designTable.MainSource.GeneratorGetMethodNameForPaging; queryGenerator.GeneratePagingMethod = true; this.GenerateQueries(classDeclaration, queryGenerator); queryGenerator.GeneratePagingMethod = false; } } } } }
private void GenerateQueries(CodeTypeDeclaration classDeclaration, QueryGenerator queryGenerator) { CodeMemberMethod method = null; if (queryGenerator.DeclarationOnly) { if (!queryGenerator.GenerateGetMethod && (queryGenerator.MethodSource.Modifier != MemberAttributes.Public)) { return; } if (queryGenerator.GenerateGetMethod && (queryGenerator.MethodSource.GetMethodModifier != MemberAttributes.Public)) { return; } } queryGenerator.ContainerParameterType = typeof(DataTable); queryGenerator.ContainerParameterTypeName = CodeGenHelper.GetTypeName(this.codeGenerator.CodeProvider, this.codeGenerator.DataSourceName, this.designTable.GeneratorTableClassName); if (this.codeGenerator.DataSetNamespace != null) { queryGenerator.ContainerParameterTypeName = CodeGenHelper.GetTypeName(this.codeGenerator.CodeProvider, this.codeGenerator.DataSetNamespace, queryGenerator.ContainerParameterTypeName); } queryGenerator.ContainerParameterName = "dataTable"; queryGenerator.ParameterOption = this.languageSupportsNullables ? ParameterGenerationOption.ClrTypes : ParameterGenerationOption.Objects; method = queryGenerator.Generate(); if (method != null) { classDeclaration.Members.Add(method); } }