Npgsql.NpgsqlCommandBuilder.QuoteIdentifier C# (CSharp) Method

QuoteIdentifier() public method

Given an unquoted identifier in the correct catalog case, returns the correct quoted form of that identifier, including properly escaping any embedded quotes in the identifier.
Unquoted identifier parameter cannot be null
public QuoteIdentifier ( string unquotedIdentifier ) : string
unquotedIdentifier string The original unquoted identifier.
return string
        public override string QuoteIdentifier(string unquotedIdentifier)

        {
            if (unquotedIdentifier == null)

            {
                throw new ArgumentNullException(nameof(unquotedIdentifier), "Unquoted identifier parameter cannot be null");
            }

            return $"{QuotePrefix}{unquotedIdentifier.Replace(QuotePrefix, QuotePrefix + QuotePrefix)}{QuoteSuffix}";
        }

Usage Example

        private static string InitSnapshotStoreSql(string tableName, string schemaName = null)
        {
            if (string.IsNullOrEmpty(tableName)) throw new ArgumentNullException("tableName", "Akka.Persistence.PostgreSql snapshot store table name is required");
            schemaName = schemaName ?? "public";

            var cb = new NpgsqlCommandBuilder();
            return string.Format(SqlSnapshotStoreFormat, cb.QuoteIdentifier(schemaName), cb.QuoteIdentifier(tableName), cb.UnquoteIdentifier(schemaName), cb.UnquoteIdentifier(tableName));
        }
All Usage Examples Of Npgsql.NpgsqlCommandBuilder::QuoteIdentifier