View Source
Class NPocoDatabaseExtensions
Provides extension methods to NPoco Database class.
Inheritance
System.Object
Assembly: Umbraco.Infrastructure.dll
Syntax
public static class NPocoDatabaseExtensions
Methods
View Source
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 |
|
View Source
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 |
|
IEnumerable<TSource> |
source |
|
System.Int32 |
groupSize |
|
Func<IEnumerable<TSource>, Sql<ISqlContext>> |
sqlFactory |
|
Returns
Type |
Description |
IEnumerable<TResult> |
|
Type Parameters
Name |
Description |
TResult |
|
TSource |
|
View Source
GetCurrentTransactionIsolationLevel(IDatabase)
Declaration
public static IsolationLevel GetCurrentTransactionIsolationLevel(this IDatabase database)
Parameters
Type |
Name |
Description |
IDatabase |
database |
|
Returns
Type |
Description |
System.Data.IsolationLevel |
|
View Source
GetTypedCommand<TCommand>(IDbCommand)
Returns the underlying command as a typed command - this is used to unwrap the profiled mini profiler stuff
Declaration
public static TCommand GetTypedCommand<TCommand>(IDbCommand command)
where TCommand : class, IDbCommand
Parameters
Type |
Name |
Description |
System.Data.IDbCommand |
command |
|
Returns
Type |
Description |
TCommand |
|
Type Parameters
Name |
Description |
TCommand |
|
View Source
GetTypedConnection<TConnection>(IDbConnection)
Returns the underlying connection as a typed connection - this is used to unwrap the profiled mini profiler stuff
Declaration
public static TConnection GetTypedConnection<TConnection>(IDbConnection connection)
where TConnection : class, IDbConnection
Parameters
Type |
Name |
Description |
System.Data.IDbConnection |
connection |
|
Returns
Type |
Description |
TConnection |
|
Type Parameters
Name |
Description |
TConnection |
|
View Source
GetTypedTransaction<TTransaction>(IDbTransaction)
Returns the underlying transaction as a typed transaction - this is used to unwrap the profiled mini profiler stuff
Declaration
public static TTransaction GetTypedTransaction<TTransaction>(IDbTransaction transaction)
where TTransaction : class, IDbTransaction
Parameters
Type |
Name |
Description |
System.Data.IDbTransaction |
transaction |
|
Returns
Type |
Description |
TTransaction |
|
Type Parameters
Name |
Description |
TTransaction |
|
View Source
IncludeColumn(PocoData, KeyValuePair<String, PocoColumn>)
Determines whether a column should be part of a bulk-insert.
Declaration
public static bool IncludeColumn(PocoData pocoData, KeyValuePair<string, PocoColumn> column)
Parameters
Type |
Name |
Description |
PocoData |
pocoData |
The PocoData object corresponding to the record's type.
|
KeyValuePair<System.String, PocoColumn> |
column |
The column.
|
Returns
Type |
Description |
System.Boolean |
A value indicating whether the column should be part of the bulk-insert.
|
Remarks
View Source
InsertOrUpdate<T>(IUmbracoDatabase, T)
Safely inserts a record, or updates if it exists, based on a unique constraint.
Declaration
public static RecordPersistenceType InsertOrUpdate<T>(this IUmbracoDatabase db, T poco)
where T : class
Parameters
Returns
Type |
Description |
RecordPersistenceType |
The action that executed, either an insert or an update. If an insert occurred and a PK value got generated, the
poco object
passed in will contain the updated value.
|
Type Parameters
View Source
InsertOrUpdate<T>(IUmbracoDatabase, T, String, Object)
Safely inserts a record, or updates if it exists, based on a unique constraint.
Declaration
public static RecordPersistenceType InsertOrUpdate<T>(this IUmbracoDatabase db, T poco, string updateCommand, object updateArgs)
where T : class
Parameters
Type |
Name |
Description |
IUmbracoDatabase |
db |
|
T |
poco |
|
System.String |
updateCommand |
If the entity has a composite key they you need to specify the update command explicitly
|
System.Object |
updateArgs |
|
Returns
Type |
Description |
RecordPersistenceType |
The action that executed, either an insert or an update. If an insert occurred and a PK value got generated, the
poco object
passed in will contain the updated value.
|
Type Parameters
View Source
QueryPaged<T>(IDatabase, Int64, Sql)
Iterates over the result of a paged data set with a db reader
Declaration
public static IEnumerable<T> QueryPaged<T>(this IDatabase database, long pageSize, Sql sql)
Parameters
Type |
Name |
Description |
IDatabase |
database |
|
System.Int64 |
pageSize |
The number of rows to load per page
|
Sql |
sql |
|
Returns
Type |
Description |
IEnumerable<T> |
|
Type Parameters
View Source
QueryPaged<T>(IDatabase, Int64, Sql, Nullable<Sql>)
Iterates over the result of a paged data set with a db reader
Declaration
public static IEnumerable<T> QueryPaged<T>(this IDatabase database, long pageSize, Sql sql, Sql? sqlCount)
Parameters
Type |
Name |
Description |
IDatabase |
database |
|
System.Int64 |
pageSize |
The number of rows to load per page
|
Sql |
sql |
|
System.Nullable<Sql> |
sqlCount |
Specify a custom Sql command to get the total count, if null is specified than the
auto-generated sql count will be used
|
Returns
Type |
Description |
IEnumerable<T> |
|
Type Parameters
View Source
TruncateTable(IDatabase, ISqlSyntaxProvider, String)
Declaration
public static void TruncateTable(this IDatabase db, ISqlSyntaxProvider sqlSyntax, string tableName)
Parameters