Npgsql.NpgsqlConnectionStringBuilder.Clone C# (CSharp) Method

Clone() public method

Return an exact copy of this NpgsqlConnectionString.
public Clone ( ) : NpgsqlConnectionStringBuilder
return NpgsqlConnectionStringBuilder
		public NpgsqlConnectionStringBuilder Clone()

		{
			NpgsqlConnectionStringBuilder builder = new NpgsqlConnectionStringBuilder();

			foreach (string key in this.Keys)

			{
				builder[key] = this[key];
			}

			return builder;
		}

Usage Example

示例#1
0
        /// <summary>
        /// This method changes the current database by disconnecting from the actual
        /// database and connecting to the specified.
        /// </summary>
        /// <param name="dbName">The name of the database to use in place of the current database.</param>
        public override void ChangeDatabase(String dbName)
        {
            CheckNotDisposed();

            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "ChangeDatabase", dbName);

            if (dbName == null)
            {
                throw new ArgumentNullException("dbName");
            }

            if (string.IsNullOrEmpty(dbName))
            {
                throw new ArgumentOutOfRangeException("dbName", dbName, String.Format(resman.GetString("Exception_InvalidDbName")));
            }

            String oldDatabaseName = Database;

            Close();

            // Mutating the current `settings` object would invalidate the cached instance, so work on a copy instead.
            settings = settings.Clone();
            settings[Keywords.Database] = dbName;
            _connectionString           = null;

            Open();
        }
All Usage Examples Of Npgsql.NpgsqlConnectionStringBuilder::Clone