Beispiel #1
0
        public async Task ConnectAsync(CancellationToken cancellationToken = default)
        {
            if (Charset.GetCharset(_options.Charset) == null)
            {
                throw FbException.Create("Invalid character set specified");
            }

            try
            {
                _db = await ClientFactory.CreateDatabaseAsync(_options, cancellationToken).ConfigureAwait(false);

                _db.Charset    = Charset.GetCharset(_options.Charset);
                _db.Dialect    = _options.Dialect;
                _db.PacketSize = _options.PacketSize;

                var dpb = BuildDpb(_db, _options);

                if (string.IsNullOrEmpty(_options.UserID) && string.IsNullOrEmpty(_options.Password))
                {
                    await _db.AttachWithTrustedAuthAsync(dpb, _options.Database, _options.CryptKey, cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    await _db.AttachAsync(dpb, _options.Database, _options.CryptKey, cancellationToken).ConfigureAwait(false);
                }
            }
            catch (IscException ex)
            {
                throw FbException.Create(ex);
            }
        }