Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PostgreSqlSqlCall"/> class.
 /// </summary>
 /// <param name="dataSource">The data source.</param>
 /// <param name="sqlStatement">The SQL statement.</param>
 /// <param name="argumentValue">The argument value.</param>
 /// <exception cref="ArgumentException">sqlStatement is null or empty.;sqlStatement</exception>
 public PostgreSqlSqlCall(PostgreSqlDataSourceBase dataSource, string sqlStatement, object?argumentValue) : base(dataSource, sqlStatement, argumentValue)
 {
     if (string.IsNullOrEmpty(sqlStatement))
     {
         throw new ArgumentException($"{nameof(sqlStatement)} is null or empty.", nameof(sqlStatement));
     }
 }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlProcedureCall"/> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="procedureName">Name of the procedure.</param>
        /// <param name="argumentValue">The argument value.</param>
        internal PostgreSqlProcedureCall(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName procedureName, object?argumentValue) : base(dataSource, argumentValue)
        {
            if (procedureName == PostgreSqlObjectName.Empty)
            {
                throw new ArgumentException($"{nameof(procedureName)} is empty", nameof(procedureName));
            }

            m_Procedure = DataSource.DatabaseMetadata.GetStoredProcedure(procedureName);
        }
Beispiel #3
0
    /// <summary>
    /// Initializes a new instance of the <see cref="PostgreSqlDeleteSet" /> class.
    /// </summary>
    /// <param name="dataSource">The data source.</param>
    /// <param name="tableName">Name of the table.</param>
    /// <param name="whereClause">The where clause.</param>
    /// <param name="parameters">The parameters.</param>
    /// <param name="expectedRowCount">The expected row count.</param>
    /// <param name="options">The options.</param>
    public PostgreSqlDeleteSet(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableName, string whereClause, IEnumerable <NpgsqlParameter> parameters, int?expectedRowCount, DeleteOptions options) : base(dataSource, whereClause, parameters, expectedRowCount, options)
    {
        if (options.HasFlag(DeleteOptions.UseKeyAttribute))
        {
            throw new NotSupportedException("Cannot use Key attributes with this operation.");
        }

        m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName);
    }
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlTableFunction" /> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="tableFunctionName">Name of the table function.</param>
        /// <param name="functionArgumentValue">The function argument.</param>
        public PostgreSqlTableFunction(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableFunctionName, object functionArgumentValue) : base(dataSource)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException("dataSource", "dataSource is null.");
            }

            m_Table = dataSource.DatabaseMetadata.GetTableFunction(tableFunctionName);
            m_FunctionArgumentValue = functionArgumentValue;
        }
Beispiel #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlTableOrView" /> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="tableOrViewName">Name of the table or view.</param>
        /// <exception cref="ArgumentException"></exception>
        public PostgreSqlTableOrView(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableOrViewName) :
            base(dataSource)
        {
            if (tableOrViewName == PostgreSqlObjectName.Empty)
            {
                throw new ArgumentException($"{nameof(tableOrViewName)} is empty", nameof(tableOrViewName));
            }

            m_Table = DataSource.DatabaseMetadata.GetTableOrView(tableOrViewName);
        }
Beispiel #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlSqlCall"/> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="sqlStatement">The SQL statement.</param>
        /// <param name="argumentValue">The argument value.</param>
        /// <exception cref="ArgumentException">sqlStatement is null or empty.;sqlStatement</exception>
        public PostgreSqlSqlCall(PostgreSqlDataSourceBase dataSource, string sqlStatement, object argumentValue) : base(dataSource)
        {
            if (string.IsNullOrEmpty(sqlStatement))
            {
                throw new ArgumentException("sqlStatement is null or empty.", "sqlStatement");
            }

            m_SqlStatement  = sqlStatement;
            m_ArgumentValue = argumentValue;
        }
Beispiel #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlUpdateMany" /> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="newValues">The new values.</param>
        /// <param name="options">The options.</param>
        /// <exception cref="System.NotSupportedException">Cannot use Key attributes with this operation.</exception>
        public PostgreSqlUpdateMany(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableName, object newValues, UpdateOptions options) : base(dataSource)
        {
            if (options.HasFlag(UpdateOptions.UseKeyAttribute))
            {
                throw new NotSupportedException("Cannot use Key attributes with this operation.");
            }

            m_Table     = dataSource.DatabaseMetadata.GetTableOrView(tableName);
            m_NewValues = newValues;
            m_Options   = options;
        }
Beispiel #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlDeleteMany" /> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="whereClause">The where clause.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="options">The options.</param>
        public PostgreSqlDeleteMany(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableName, string whereClause, IEnumerable <NpgsqlParameter> parameters, DeleteOptions options) : base(dataSource)
        {
            if (options.HasFlag(DeleteOptions.UseKeyAttribute))
            {
                throw new NotSupportedException("Cannot use Key attributes with this operation.");
            }

            m_Table       = dataSource.DatabaseMetadata.GetTableOrView(tableName);
            m_WhereClause = whereClause;
            //m_Options = options;
            m_Parameters = parameters;
        }
Beispiel #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlTableOrView"/> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="tableOrViewName">Name of the table or view.</param>
        /// <param name="whereClause">The where clause.</param>
        /// <param name="argumentValue">The argument value.</param>
        /// <exception cref="ArgumentException"></exception>
        public PostgreSqlTableOrView(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableOrViewName, string whereClause, object argumentValue)
            : base(dataSource)
        {
            if (tableOrViewName == PostgreSqlObjectName.Empty)
            {
                throw new ArgumentException($"{nameof(tableOrViewName)} is empty", nameof(tableOrViewName));
            }

            m_WhereClause   = whereClause;
            m_ArgumentValue = argumentValue;
            m_Table         = DataSource.DatabaseMetadata.GetTableOrView(tableOrViewName);
        }
Beispiel #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlTableOrView" /> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="tableOrViewName">Name of the table or view.</param>
        /// <param name="filterValue">The filter value.</param>
        /// <param name="filterOptions">The filter options.</param>
        /// <exception cref="System.ArgumentException"></exception>
        /// <exception cref="ArgumentException"></exception>
        public PostgreSqlTableOrView(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableOrViewName, object filterValue, FilterOptions filterOptions = FilterOptions.None) :
            base(dataSource)
        {
            if (tableOrViewName == PostgreSqlObjectName.Empty)
            {
                throw new ArgumentException($"{nameof(tableOrViewName)} is empty", nameof(tableOrViewName));
            }

            m_FilterValue   = filterValue;
            m_FilterOptions = filterOptions;
            m_Table         = DataSource.DatabaseMetadata.GetTableOrView(tableOrViewName);
        }
Beispiel #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlUpdateMany" /> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="updateExpression">The update expression.</param>
        /// <param name="updateArgumentValue">The update argument value.</param>
        /// <param name="options">The options.</param>
        /// <exception cref="System.NotSupportedException">Cannot use Key attributes with this operation.</exception>
        public PostgreSqlUpdateMany(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableName, string updateExpression, object updateArgumentValue, UpdateOptions options) : base(dataSource)
        {
            if (options.HasFlag(UpdateOptions.UseKeyAttribute))
            {
                throw new NotSupportedException("Cannot use Key attributes with this operation.");
            }

            m_Table               = dataSource.DatabaseMetadata.GetTableOrView(tableName);
            m_UpdateExpression    = updateExpression;
            m_Options             = options;
            m_UpdateArgumentValue = updateArgumentValue;
        }
Beispiel #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostgreSqlUpdateMany" /> class.
        /// </summary>
        /// <param name="dataSource">The data source.</param>
        /// <param name="tableName">Name of the table.</param>
        /// <param name="newValues">The new values.</param>
        /// <param name="whereClause">The where clause.</param>
        /// <param name="parameters">The parameters.</param>
        /// <param name="expectedRowCount">The expected row count.</param>
        /// <param name="options">The options.</param>
        public PostgreSqlUpdateMany(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableName, object newValues, string whereClause, IEnumerable <NpgsqlParameter> parameters, int?expectedRowCount, UpdateOptions options) : base(dataSource)
        {
            if (options.HasFlag(UpdateOptions.UseKeyAttribute))
            {
                throw new NotSupportedException("Cannot use Key attributes with this operation.");
            }

            m_Table            = dataSource.DatabaseMetadata.GetTableOrView(tableName);
            m_NewValues        = newValues;
            m_WhereClause      = whereClause;
            m_ExpectedRowCount = expectedRowCount;
            m_Options          = options;
            m_Parameters       = parameters;
        }
        public PostgreSqlInsertBatch(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableName, IEnumerable <TObject> objects, InsertOptions options) : base(dataSource)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException(nameof(dataSource), $"{nameof(dataSource)} is null.");
            }

            var sourceList = objects.AsReadOnlyList();

            if (sourceList == null || sourceList.Count == 0)
            {
                throw new ArgumentException($"{nameof(objects)} is null or empty.", nameof(objects));
            }

            m_SourceList = sourceList;
            m_Options    = options;
            m_Table      = dataSource.DatabaseMetadata.GetTableOrView(tableName);
        }
Beispiel #14
0
        internal PostgreSqlInsertBulk(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableName, IDataReader dataReader) : base(dataSource)
        {
            if (dataSource == null)
            {
                throw new ArgumentNullException(nameof(dataSource), $"{nameof(dataSource)} is null.");
            }
            if (dataReader == null)
            {
                throw new ArgumentNullException(nameof(dataReader), $"{nameof(dataReader)} is null.");
            }

            m_DataSource = dataSource;
            m_Source     = dataReader;
            m_Table      = dataSource.DatabaseMetadata.GetTableOrView(tableName);
            if (!m_Table.IsTable)
            {
                throw new MappingException($"Cannot perform a bulk insert into the view {m_Table.Name}");
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PostgreSqlScalarFunction" /> class.
 /// </summary>
 /// <param name="dataSource">The data source.</param>
 /// <param name="scalarFunctionName">Name of the scalar function.</param>
 /// <param name="functionArgumentValue">The function argument.</param>
 public PostgreSqlScalarFunction(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName scalarFunctionName, object?functionArgumentValue) : base(dataSource, functionArgumentValue)
 {
     m_Function = dataSource.DatabaseMetadata.GetScalarFunction(scalarFunctionName);
 }
Beispiel #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PostgreSqlDeleteSet"/> class.
 /// </summary>
 /// <param name="dataSource">The data source.</param>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="whereClause">The where clause.</param>
 /// <param name="argumentValue">The argument value.</param>
 public PostgreSqlDeleteSet(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableName, string whereClause, object?argumentValue) : base(dataSource, whereClause, argumentValue)
 {
     m_Table = dataSource.DatabaseMetadata.GetTableOrView(tableName);
 }
Beispiel #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PostgreSqlInsertObject{TArgument}"/> class.
 /// </summary>
 /// <param name="dataSource">The data source.</param>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="argumentValue">The argument value.</param>
 /// <param name="options">The options.</param>
 public PostgreSqlInsertObject(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableName, TArgument argumentValue, InsertOptions options)
     : base(dataSource, tableName, argumentValue)
 {
     m_Options = options;
 }
Beispiel #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PostgreSqlDeleteMany"/> class.
 /// </summary>
 /// <param name="dataSource">The data source.</param>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="filterValue">The filter value.</param>
 /// <param name="filterOptions">The options.</param>
 public PostgreSqlDeleteMany(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableName, object filterValue, FilterOptions filterOptions) : base(dataSource)
 {
     m_Table         = dataSource.DatabaseMetadata.GetTableOrView(tableName);
     m_FilterValue   = filterValue;
     m_FilterOptions = filterOptions;
 }
Beispiel #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PostgreSqlDeleteMany"/> class.
 /// </summary>
 /// <param name="dataSource">The data source.</param>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="whereClause">The where clause.</param>
 /// <param name="argumentValue">The argument value.</param>
 public PostgreSqlDeleteMany(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableName, string whereClause, object?argumentValue) : base(dataSource)
 {
     m_Table         = dataSource.DatabaseMetadata.GetTableOrView(tableName);
     m_WhereClause   = whereClause;
     m_ArgumentValue = argumentValue;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PostgreSqlObjectCommand{TArgument}"/> class.
 /// </summary>
 /// <param name="dataSource">The data source.</param>
 /// <param name="tableName">Name of the table.</param>
 /// <param name="argumentValue">The argument value.</param>
 protected PostgreSqlObjectCommand(PostgreSqlDataSourceBase dataSource, PostgreSqlObjectName tableName, TArgument argumentValue)
     : base(dataSource, argumentValue)
 {
     Table = dataSource.DatabaseMetadata.GetTableOrView(tableName);
 }