public override DataTable GetSchemaTable()
    {
        CheckState();

        if (_schemaTable != null)
        {
            return(_schemaTable);
        }

        DataRow schemaRow    = null;
        var     tableCount   = 0;
        var     currentTable = string.Empty;

        _schemaTable = GetSchemaTableStructure();

        /* Prepare statement for schema fields information	*/
        var schemaCmd = new FbCommand(GetSchemaCommandText(), _command.Connection, _command.Connection.InnerConnection.ActiveTransaction);

        try
        {
            schemaCmd.Parameters.Add("@TABLE_NAME", FbDbType.Char, 31);
            schemaCmd.Parameters.Add("@COLUMN_NAME", FbDbType.Char, 31);
            schemaCmd.Prepare();

            _schemaTable.BeginLoadData();

            for (var i = 0; i < _fields.Count; i++)
            {
                var isKeyColumn  = false;
                var isUnique     = false;
                var isReadOnly   = false;
                var precision    = 0;
                var isExpression = false;

                /* Get Schema data for the field	*/
                schemaCmd.Parameters[0].Value = _fields[i].Relation;
                schemaCmd.Parameters[1].Value = _fields[i].Name;

                var reader = schemaCmd.ExecuteReader(CommandBehavior.Default);
                try
                {
                    if (reader.Read())
                    {
                        isReadOnly   = (IsReadOnly(reader) || IsExpression(reader)) ? true : false;
                        isKeyColumn  = (reader.GetInt32(2) == 1) ? true : false;
                        isUnique     = (reader.GetInt32(3) == 1) ? true : false;
                        precision    = reader.IsDBNull(4) ? -1 : reader.GetInt32(4);
                        isExpression = IsExpression(reader);
                    }
                }
                finally
                {
#if NET48 || NETSTANDARD2_0
                    reader.Dispose();
#else
                    reader.Dispose();
#endif
                }

                /* Create new row for the Schema Table	*/
                schemaRow = _schemaTable.NewRow();

                schemaRow["ColumnName"]    = GetName(i);
                schemaRow["ColumnOrdinal"] = i;
                schemaRow["ColumnSize"]    = _fields[i].GetSize();
                if (_fields[i].IsDecimal())
                {
                    schemaRow["NumericPrecision"] = schemaRow["ColumnSize"];
                    if (precision > 0)
                    {
                        schemaRow["NumericPrecision"] = precision;
                    }
                    schemaRow["NumericScale"] = _fields[i].NumericScale * (-1);
                }
                schemaRow["DataType"]        = GetFieldType(i);
                schemaRow["ProviderType"]    = GetProviderType(i);
                schemaRow["IsLong"]          = _fields[i].IsLong();
                schemaRow["AllowDBNull"]     = _fields[i].AllowDBNull();
                schemaRow["IsRowVersion"]    = false;
                schemaRow["IsAutoIncrement"] = false;
                schemaRow["IsReadOnly"]      = isReadOnly;
                schemaRow["IsKey"]           = isKeyColumn;
                schemaRow["IsUnique"]        = isUnique;
                schemaRow["IsAliased"]       = _fields[i].IsAliased();
                schemaRow["IsExpression"]    = isExpression;
                schemaRow["BaseSchemaName"]  = DBNull.Value;
                schemaRow["BaseCatalogName"] = DBNull.Value;
                schemaRow["BaseTableName"]   = _fields[i].Relation;
                schemaRow["BaseColumnName"]  = _fields[i].Name;

                _schemaTable.Rows.Add(schemaRow);

                if (!string.IsNullOrEmpty(_fields[i].Relation) && currentTable != _fields[i].Relation)
                {
                    tableCount++;
                    currentTable = _fields[i].Relation;
                }

                schemaCmd.Close();
            }

            if (tableCount > 1)
            {
                foreach (DataRow row in _schemaTable.Rows)
                {
                    row["IsKey"]    = false;
                    row["IsUnique"] = false;
                }
            }

            _schemaTable.EndLoadData();
        }
        finally
        {
#if NET48 || NETSTANDARD2_0
            schemaCmd.Dispose();
#else
            schemaCmd.Dispose();
#endif
        }

        return(_schemaTable);
    }