Ejemplo n.º 1
0
        // Extensions on the PostgresInsert type (i.e. not the plain Insert type)

        /// <summary>
        /// Adds a Postgres ON CONFLICT clause to an INSERT statement.
        /// statement.
        /// </summary>
        /// <param name="insert">The insert action to add to.</param>
        /// <param name="target">The target for the ON CONFLICT clause.</param>
        /// <param name="action">The action for the ON CONFLICT clause.</param>
        /// <returns>A Postgres-type INSERT statement with the specified clause.</returns>
        public static PostgresInsert OnConflict(
            this PostgresInsert insert,
            IEnumerable <ISqlElement> target,
            Update action)
        {
            insert.OnConflict = new PostgresOnConflict
            {
                Target = new ColumnCollection {
                    target
                },
                DoUpdate = action
            };
            return(insert);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a Postgres ON CONFLICT DO NOTHING clause to an INSERT statement.
 /// </summary>
 /// <param name="insert">The insert action to add to.</param>
 /// <returns>A Postgres-type INSERT statement with the specified clause.</returns>
 public static PostgresInsert OnConflictDoNothing(this PostgresInsert insert)
 {
     insert.OnConflict = new PostgresOnConflict();
     return(insert);
 }