public void Set(IDesignConnection connection) { INamedObject obj2 = NamedObjectUtil.Find(this, connection.Name); if (obj2 != null) { base.List.Remove(obj2); } base.List.Add(connection); }
public void Set(IDesignConnection connection) { INamedObject obj2 = NamedObjectUtil.Find(this, connection.Name); if (obj2 != null) { base.List.Remove(obj2); } base.List.Add(connection); }
protected override void OnSet(int index, object oldValue, object newValue) { base.OnSet(index, oldValue, newValue); base.ValidateType(newValue); IDesignConnection connection = (IDesignConnection)oldValue; IDesignConnection connection2 = (IDesignConnection)newValue; if (!StringUtil.EqualValue(connection.Name, connection2.Name)) { this.ValidateUniqueName(connection2, connection2.Name); } }
private void SetConnectionProperty(Source source) { DbSource source2 = source as DbSource; if (source2 != null) { string connectionRef = source2.ConnectionRef; if ((connectionRef != null) && (connectionRef.Length != 0)) { IDesignConnection connection = this.DesignConnections.Get(connectionRef); if (connection != null) { source2.Connection = connection; } } } }
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 }))); } } }
private void AddInitConnection(CodeTypeDeclaration dataComponentClass) { IDesignConnection connection = this.designTable.Connection; CodeMemberMethod method = CodeGenHelper.MethodDecl(CodeGenHelper.GlobalType(typeof(void)), DataComponentNameHandler.InitConnection, MemberAttributes.Private | MemberAttributes.Final); method.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.DefaultConnectionVariableName), CodeGenHelper.New(CodeGenHelper.GlobalType(this.providerFactory.CreateConnection().GetType()), new CodeExpression[0]))); CodeExpression right = null; if (connection.PropertyReference == null) { right = CodeGenHelper.Str(connection.ConnectionStringObject.ToFullString()); } else { right = connection.PropertyReference; } method.Statements.Add(CodeGenHelper.Assign(CodeGenHelper.Property(CodeGenHelper.Field(CodeGenHelper.This(), DataComponentNameHandler.DefaultConnectionVariableName), "ConnectionString"), right)); dataComponentClass.Members.Add(method); }
private Type GetParameterSqlType(DesignParameter parameter) { IDesignConnection connection = null; if (!StringUtil.EqualValue(connection.Provider, ManagedProviderNames.SqlClient)) { throw new InternalException("We should never attempt to generate SqlType-parameters for non-Sql providers."); } SqlDbType sqlDbType = SqlDbType.Char; bool flag = false; if ((parameter.ProviderType != null) && (parameter.ProviderType.Length > 0)) { try { sqlDbType = (SqlDbType)Enum.Parse(typeof(SqlDbType), parameter.ProviderType); flag = true; } catch { } } if (!flag) { SqlParameter parameter2 = new SqlParameter { DbType = parameter.DbType }; sqlDbType = parameter2.SqlDbType; } Type type2 = TypeConvertions.SqlDbTypeToSqlType(sqlDbType); if (type2 != null) { return(type2); } if (this.codeGenerator != null) { this.codeGenerator.ProblemList.Add(new DSGeneratorProblem(System.Design.SR.GetString("CG_UnableToConvertSqlDbTypeToSqlType", new object[] { this.MethodName, parameter.Name }), ProblemSeverity.NonFatalError, this.methodSource)); } return(typeof(object)); }
public void Remove(IDesignConnection connection) { base.List.Remove(connection); }
public bool Contains(IDesignConnection connection) { return base.List.Contains(connection); }
public int Add(IDesignConnection connection) { return base.List.Add(connection); }
public void Remove(IDesignConnection connection) { base.List.Remove(connection); }
public bool Contains(IDesignConnection connection) { return(base.List.Contains(connection)); }
public int Add(IDesignConnection connection) { return(base.List.Add(connection)); }