Class NPocoDatabaseExtensions
Provides extension methods to NPoco Database class.
Inheritance
Namespace: Umbraco.Core.Persistence
Assembly: Umbraco.Core.dll
Syntax
public static class NPocoDatabaseExtensions
Methods
View SourceBulkInsertRecords<T>(IUmbracoDatabase, IEnumerable<T>, Boolean)
Bulk-inserts records.
Declaration
public static int BulkInsertRecords<T>(this IUmbracoDatabase database, IEnumerable<T> records, bool useNativeBulkInsert = true)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoDatabase | database | The database. |
System.Collections.Generic.IEnumerable<T> | records | The records. |
System.Boolean | useNativeBulkInsert | Whether to use native bulk insert when available. |
Returns
Type | Description |
---|---|
System.Int32 | The number of records that were inserted. |
Type Parameters
Name | Description |
---|---|
T | The type of the records. |
BulkInsertRecordsWithTransaction<T>(IUmbracoDatabase, IEnumerable<T>, Boolean)
Bulk-inserts records within a transaction.
Declaration
public static void BulkInsertRecordsWithTransaction<T>(this IUmbracoDatabase database, IEnumerable<T> records, bool useNativeBulkInsert = true)
Parameters
Type | Name | Description |
---|---|---|
IUmbracoDatabase | database | The database. |
System.Collections.Generic.IEnumerable<T> | records | The records. |
System.Boolean | useNativeBulkInsert | Whether to use native bulk insert when available. |
Type Parameters
Name | Description |
---|---|
T | The type of the records. |
ConfigureNPocoBulkExtensions()
Configures NPoco's SqlBulkCopyHelper to use the correct SqlConnection and SqlTransaction instances from the underlying RetryDbConnection and ProfiledDbTransaction
Declaration
public static void ConfigureNPocoBulkExtensions()
Remarks
This is required to use NPoco's own
EscapeAtSymbols(String)
This will escape single @ symbols for npoco values so it doesn't think it's a parameter
Declaration
public static string EscapeAtSymbols(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value |
Returns
Type | Description |
---|---|
System.String |
FetchByGroups<TResult, TSource>(IDatabase, IEnumerable<TSource>, Int32, Func<IEnumerable<TSource>, Sql<ISqlContext>>)
Declaration
public static IEnumerable<TResult> FetchByGroups<TResult, TSource>(this IDatabase db, IEnumerable<TSource> source, int groupSize, Func<IEnumerable<TSource>, Sql<ISqlContext>> sqlFactory)
Parameters
Type | Name | Description |
---|---|---|
IDatabase | db | |
System.Collections.Generic.IEnumerable<TSource> | source | |
System.Int32 | groupSize | |
System.Func<System.Collections.Generic.IEnumerable<TSource>, Sql<ISqlContext>> | sqlFactory |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<TResult> |
Type Parameters
Name | Description |
---|---|
TResult | |
TSource |
GetCurrentTransactionIsolationLevel(IDatabase)
Declaration
public static IsolationLevel GetCurrentTransactionIsolationLevel(this IDatabase database)
Parameters
Type | Name | Description |
---|---|---|
IDatabase | database |
Returns
Type | Description |
---|---|
System.Data.IsolationLevel |
TruncateTable(IDatabase, ISqlSyntaxProvider, String)
Declaration
public static void TruncateTable(this IDatabase db, ISqlSyntaxProvider sqlSyntax, string tableName)
Parameters
Type | Name | Description |
---|---|---|
IDatabase | db | |
ISqlSyntaxProvider | sqlSyntax | |
System.String | tableName |