コード例 #1
0
        /// <inheritdoc/>
        protected override string BuildConnectionString(UrlInfo connectionUrl)
        {
            SqlHelper.ValidateConnectionUrl(connectionUrl);
            ArgumentValidator.EnsureArgumentNotNullOrEmpty(connectionUrl.Resource, "connectionUrl.Resource");
            ArgumentValidator.EnsureArgumentNotNullOrEmpty(connectionUrl.Host, "connectionUrl.Host");

            var builder = new FbConnectionStringBuilder();

            // host, port, database
            if (!string.IsNullOrEmpty(connectionUrl.Host))
            {
                var port = connectionUrl.Port != 0 ? connectionUrl.Port : DefaultPort;
                builder.Database              = connectionUrl.Resource;
                builder.DataSource            = connectionUrl.Host;
                builder.Dialect               = 3;
                builder.Pooling               = false;
                builder.Port                  = port;
                builder.ReturnRecordsAffected = true;
            }

            // user, password
            if (!string.IsNullOrEmpty(connectionUrl.User))
            {
                builder.UserID   = connectionUrl.User;
                builder.Password = connectionUrl.Password;
            }

            // custom options
            foreach (var parameter in connectionUrl.Params)
            {
                builder.Add(parameter.Key, parameter.Value);
            }

            return(builder.ToString());
        }