Search Results for

    Show / Hide Table of Contents

    Class SqlConnectionExtensions

    SQL connection extensions

    Inheritance
    Object
    SqlConnectionExtensions
    Namespace: Gossip.Connection
    Assembly: Gossip.dll
    Syntax
    public static class SqlConnectionExtensions : object

    Methods

    | Improve this Doc View Source

    BulkInsert<T>(SqlConnection, String, IEnumerable<T>, Int32, Action<Object, SqlRowsCopiedEventArgs>, Int32, Dictionary<String, String>, Int32)

    This uses reflection to get the properties of your object.

    Then transforms your objects into a DataTable

    Then uses SqlBulkCopy to put it into SQL

    Declaration
    public static void BulkInsert<T>(this SqlConnection connection, string insertIntoTable, IEnumerable<T> data, int batchSize = 1000, Action<object, SqlRowsCopiedEventArgs> notifyCallback = null, int notifyAfter = 10000, Dictionary<string, string> columnMapping = null, int timeoutSeconds = 30)
    Parameters
    Type Name Description
    SqlConnection connection

    Connection

    String insertIntoTable

    Table

    IEnumerable<T> data

    Currently this method is stupid, the type's properties should match the database table columns, if not use the column mapping dictionary

    Int32 batchSize

    Batch size

    Action<Object, SqlRowsCopiedEventArgs> notifyCallback

    Callback

    Int32 notifyAfter

    Notify

    Dictionary<String, String> columnMapping

    Manual mapping of object property names to database column names

    Int32 timeoutSeconds

    Timeout the queries after

    Type Parameters
    Name Description
    T

    Generic Type

    | Improve this Doc View Source

    BulkInsertAsync<T>(SqlConnection, String, IEnumerable<T>, Int32, Action<Object, SqlRowsCopiedEventArgs>, Int32, Dictionary<String, String>, Int32)

    This uses reflection to get the properties of your object.

    Then transforms your objects into a DataTable

    Then uses SqlBulkCopy to put it into SQL

    Declaration
    public static Task BulkInsertAsync<T>(this SqlConnection connection, string insertIntoTable, IEnumerable<T> data, int batchSize = 1000, Action<object, SqlRowsCopiedEventArgs> notifyCallback = null, int notifyAfter = 10000, Dictionary<string, string> columnMapping = null, int timeoutSeconds = 30)
    Parameters
    Type Name Description
    SqlConnection connection

    Connection

    String insertIntoTable

    Table

    IEnumerable<T> data

    Currently this method is stupid, the type's properties should match the database table columns, if not use the column mapping dictionary

    Int32 batchSize

    Batch Size

    Action<Object, SqlRowsCopiedEventArgs> notifyCallback

    Callback Function

    Int32 notifyAfter

    Notify

    Dictionary<String, String> columnMapping

    Manual mapping of object property names to database column names

    Int32 timeoutSeconds

    Timeout the queries after

    Returns
    Type Description
    Task
    Type Parameters
    Name Description
    T

    Generic Type

    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX