Exemple #1
0
        public static async Task <bool> FunctionExists(this NpgsqlConnection conn, DbObjectName functionIdentifier)
        {
            var sql =
                "SELECT specific_schema, routine_name FROM information_schema.routines WHERE type_udt_name != 'trigger' and routine_name like :name and specific_schema = :schema;";

            using var reader = await conn.CreateCommand(sql)
                               .With("name", functionIdentifier.Name)
                               .With("schema", functionIdentifier.Schema)

                               .ExecuteReaderAsync();

            return(await reader.ReadAsync());
        }
Exemple #2
0
        public static NpgsqlCommand CallsSproc(this NpgsqlCommand cmd, DbObjectName function)
        {
            if (cmd == null)
            {
                throw new ArgumentNullException(nameof(cmd));
            }
            if (function == null)
            {
                throw new ArgumentNullException(nameof(function));
            }

            cmd.CommandText = function.QualifiedName;
            cmd.CommandType = CommandType.StoredProcedure;

            return(cmd);
        }
Exemple #3
0
 internal static string ToIndexName(this DbObjectName name, string prefix, params string[] columnNames)
 {
     return($"{prefix}_{name.Name}_{columnNames.Join("_")}");
 }
Exemple #4
0
        public static Task <Function> FindExistingFunction(this NpgsqlConnection conn, DbObjectName functionName)
        {
            var function = new Function(functionName, null);

            return(function.FetchExisting(conn));
        }
Exemple #5
0
 protected bool Equals(DbObjectName other)
 {
     return(GetType() == other.GetType() && string.Equals(QualifiedName, other.QualifiedName, StringComparison.OrdinalIgnoreCase));
 }
Exemple #6
0
 public Sequence(DbObjectName identifier, long startWith)
 {
     Identifier = identifier;
     _startWith = startWith;
 }
Exemple #7
0
 public Sequence(DbObjectName identifier)
 {
     Identifier = identifier;
 }
Exemple #8
0
 public Sequence(string identifier)
 {
     Identifier = DbObjectName.Parse(identifier);
 }
Exemple #9
0
 public Sequence(string identifier)
 {
     Identifier = DbObjectName.Parse(PostgresqlProvider.Instance, identifier);
 }