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 AddCommandInitStatements(IList statements, CodeExpression commandExpression, DbSourceCommand command, DbProviderFactory currentFactory, bool isFunctionsDataComponent) { if (((statements == null) || (commandExpression == null)) || (command == null)) { throw new InternalException("Argument should not be null."); } Type parameterType = currentFactory.CreateParameter().GetType(); Type type = currentFactory.CreateCommand().GetType(); CodeExpression parameterVariable = null; statements.Add(CodeGenHelper.Assign(commandExpression, CodeGenHelper.New(CodeGenHelper.GlobalType(type), new CodeExpression[0]))); if (isFunctionsDataComponent) { commandExpression = CodeGenHelper.Cast(CodeGenHelper.GlobalType(type), commandExpression); } if ((((DbSource)command.Parent).Connection == null) || ((this.designTable.Connection != null) && (this.designTable.Connection == ((DbSource)command.Parent).Connection))) { statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(commandExpression, "Connection"), CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.DefaultConnectionPropertyName))); } else { Type type3 = currentFactory.CreateConnection().GetType(); IDesignConnection connection = ((DbSource)command.Parent).Connection; CodeExpression propertyReference = null; if (connection.PropertyReference == null) { propertyReference = CodeGenHelper.Str(connection.ConnectionStringObject.ToFullString()); } else { propertyReference = connection.PropertyReference; } statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(commandExpression, "Connection"), CodeGenHelper.New(CodeGenHelper.GlobalType(type3), new CodeExpression[] { propertyReference }))); } statements.Add(QueryGeneratorBase.SetCommandTextStatement(commandExpression, command.CommandText)); statements.Add(QueryGeneratorBase.SetCommandTypeStatement(commandExpression, command.CommandType)); if (command.Parameters != null) { foreach (DesignParameter parameter in command.Parameters) { parameterVariable = QueryGeneratorBase.AddNewParameterStatements(parameter, parameterType, currentFactory, statements, parameterVariable); statements.Add(CodeGenHelper.Stm(CodeGenHelper.MethodCall(CodeGenHelper.Property(commandExpression, "Parameters"), "Add", new CodeExpression[] { parameterVariable }))); } } }
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()); }