private bool AddSetCommandStatements(IList statements) { Type type = base.ProviderFactory.CreateCommand().GetType(); CodeExpression expr = CodeGenHelper.ArrayIndexer(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.SelectCmdCollectionPropertyName), CodeGenHelper.Primitive(base.CommandIndex)); if (base.IsFunctionsDataComponent) { expr = CodeGenHelper.Cast(CodeGenHelper.GlobalType(type), expr); } statements.Add(CodeGenHelper.VariableDecl(CodeGenHelper.GlobalType(type), QueryGeneratorBase.commandVariableName, expr)); return(true); }
private bool AddSetCommandStatements(IList statements) { base.ProviderFactory.CreateCommand().GetType(); statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.AdapterPropertyName), "SelectCommand"), CodeGenHelper.ArrayIndexer(CodeGenHelper.Property(CodeGenHelper.This(), DataComponentNameHandler.SelectCmdCollectionPropertyName), CodeGenHelper.Primitive(base.CommandIndex)))); return(true); }
private void AddInitCommandCollection(CodeTypeDeclaration dataComponentClass, bool isFunctionsDataComponent) { int count = this.designTable.Sources.Count; if (!isFunctionsDataComponent) { count++; } CodeMemberMethod method = CodeGenHelper.MethodDecl(CodeGenHelper.GlobalType(typeof(void)), DataComponentNameHandler.InitCmdCollection, MemberAttributes.Private | MemberAttributes.Final); Type type = null; if (isFunctionsDataComponent) { type = typeof(IDbCommand); } else { type = this.providerFactory.CreateCommand().GetType(); } method.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.SelectCmdCollectionVariableName), CodeGenHelper.NewArray(CodeGenHelper.GlobalType(type), count))); if ((!isFunctionsDataComponent && (this.designTable.MainSource != null)) && (this.designTable.MainSource is DbSource)) { DbSourceCommand activeCommand = ((DbSource)this.designTable.MainSource).GetActiveCommand(); if (activeCommand != null) { CodeExpression commandExpression = CodeGenHelper.ArrayIndexer(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.SelectCmdCollectionVariableName), CodeGenHelper.Primitive(0)); this.AddCommandInitStatements(method.Statements, commandExpression, activeCommand, this.providerFactory, isFunctionsDataComponent); } } if (this.designTable.Sources != null) { int primitive = 0; if (isFunctionsDataComponent) { primitive--; } foreach (Source source2 in this.designTable.Sources) { DbSource source3 = source2 as DbSource; primitive++; if (source3 != null) { DbProviderFactory providerFactory = this.providerFactory; if (source3.Connection != null) { providerFactory = ProviderManager.GetFactory(source3.Connection.Provider); } if (providerFactory != null) { DbSourceCommand command = source3.GetActiveCommand(); if (command != null) { CodeExpression expression2 = CodeGenHelper.ArrayIndexer(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.SelectCmdCollectionVariableName), CodeGenHelper.Primitive(primitive)); this.AddCommandInitStatements(method.Statements, expression2, command, providerFactory, isFunctionsDataComponent); } } } } } dataComponentClass.Members.Add(method); }