Skip to main content

OrmLiteReadApiAsync

Assembly: ServiceStack.OrmLite.dll
View Source
Declaration
public static class OrmLiteReadApiAsync : object

Methods

SelectAsync<T>(IDbConnection, CancellationToken)

Returns results from the active connection, E.g: <p>db.SelectAsync<Person>()</p>

View Source
Declaration
public static Task<List<T>> SelectAsync<T>(this IDbConnection dbConn, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
CancellationTokentoken
Type Parameters
  • T

SelectAsync<T>(IDbConnection, String, CancellationToken)

Returns results from using sql. E.g: <p>db.SelectAsync<Person>("Age > 40")</p> <p>db.SelectAsync<Person>("SELECT * FROM Person WHERE Age > 40")</p>

View Source
Declaration
public static Task<List<T>> SelectAsync<T>(this IDbConnection dbConn, string sql, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
CancellationTokentoken
Type Parameters
  • T

SelectAsync<T>(IDbConnection, String, IEnumerable<IDbDataParameter>, CancellationToken)

Returns results from using a parameterized query. E.g: <p>db.SelectAsync<Person>("Age > @age", new { age = 40})</p> <p>db.SelectAsync<Person>("SELECT * FROM Person WHERE Age > @age", new[] { db.CreateParam("age",40) })</p>

View Source
Declaration
public static Task<List<T>> SelectAsync<T>(this IDbConnection dbConn, string sql, IEnumerable<IDbDataParameter> sqlParams, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
IEnumerable<IDbDataParameter>sqlParams
CancellationTokentoken
Type Parameters
  • T

SelectAsync<T>(IDbConnection, String, Object, CancellationToken)

Returns results from using a parameterized query. E.g: <p>db.SelectAsync<Person>("Age > @age", new { age = 40})</p> <p>db.SelectAsync<Person>("SELECT * FROM Person WHERE Age > @age", new { age = 40})</p>

View Source
Declaration
public static Task<List<T>> SelectAsync<T>(this IDbConnection dbConn, string sql, object anonType, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • T

SelectAsync<T>(IDbConnection, String, Dictionary<String, Object>, CancellationToken)

Returns results from using a parameterized query. E.g: <p>db.SelectAsync<Person>("Age > @age", new Dictionary<string, object> { { "age", 40 } })</p> <p>db.SelectAsync<Person>("SELECT * FROM Person WHERE Age > @age", new Dictionary<string, object> { { "age", 40 } })</p>

View Source
Declaration
public static Task<List<T>> SelectAsync<T>(this IDbConnection dbConn, string sql, Dictionary<string, object> dict, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
Dictionary<System.String,System.Object>dict
CancellationTokentoken
Type Parameters
  • T

SelectAsync<TModel>(IDbConnection, Type, CancellationToken)

Returns a partial subset of results from the specified tableType. E.g: <p>db.SelectAsync<EntityWithId>(typeof(Person))</p> <p></p>

View Source
Declaration
public static Task<List<TModel>> SelectAsync<TModel>(this IDbConnection dbConn, Type fromTableType, CancellationToken token = null)
Returns

Task<List<<TModel>>>

Parameters
TypeName
IDbConnectiondbConn
TypefromTableType
CancellationTokentoken
Type Parameters
  • TModel

SelectAsync<TModel>(IDbConnection, Type, String, Object, CancellationToken)

Returns a partial subset of results from the specified tableType. E.g: <p>db.SelectAsync<EntityWithId>(typeof(Person), "Age = @age", new { age = 27 })</p> <p></p>

View Source
Declaration
public static Task<List<TModel>> SelectAsync<TModel>(this IDbConnection dbConn, Type fromTableType, string sqlFilter, object anonType = null, CancellationToken token = null)
Returns

Task<List<<TModel>>>

Parameters
TypeName
IDbConnectiondbConn
TypefromTableType
System.StringsqlFilter
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • TModel

WhereAsync<T>(IDbConnection, String, Object, CancellationToken)

Returns results from using a single name, value filter. E.g: <p>db.WhereAsync<Person>("Age", 27)</p>

View Source
Declaration
public static Task<List<T>> WhereAsync<T>(this IDbConnection dbConn, string name, object value, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringname
System.Objectvalue
CancellationTokentoken
Type Parameters
  • T

WhereAsync<T>(IDbConnection, Object, CancellationToken)

Returns results from using an anonymous type filter. E.g: <p>db.WhereAsync<Person>(new { Age = 27 })</p>

View Source
Declaration
public static Task<List<T>> WhereAsync<T>(this IDbConnection dbConn, object anonType, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • T

SelectByIdsAsync<T>(IDbConnection, IEnumerable, CancellationToken)

Returns results using the supplied primary key ids. E.g: <p>db.SelectByIdsAsync<Person>(new[] { 1, 2, 3 })</p>

View Source
Declaration
public static Task<List<T>> SelectByIdsAsync<T>(this IDbConnection dbConn, IEnumerable idValues, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
IEnumerableidValues
CancellationTokentoken
Type Parameters
  • T

SelectNonDefaultsAsync<T>(IDbConnection, T, CancellationToken)

Query results using the non-default values in the supplied partially populated POCO example. E.g: <p>db.SelectNonDefaultsAsync(new Person { Id = 1 })</p>

View Source
Declaration
public static Task<List<T>> SelectNonDefaultsAsync<T>(this IDbConnection dbConn, T filter, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
<T>filter
CancellationTokentoken
Type Parameters
  • T

SelectNonDefaultsAsync<T>(IDbConnection, String, T, CancellationToken)

Query results using the non-default values in the supplied partially populated POCO example. E.g: <p>db.SelectNonDefaultsAsync("Age > @Age", new Person { Age = 42 })</p>

View Source
Declaration
public static Task<List<T>> SelectNonDefaultsAsync<T>(this IDbConnection dbConn, string sql, T filter, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
<T>filter
CancellationTokentoken
Type Parameters
  • T

SingleAsync<T>(IDbConnection, Object, CancellationToken)

Returns the first result using a parameterized query. E.g: <p>db.SingleAsync<Person>(new { Age = 42 })</p>

View Source
Declaration
public static Task<T> SingleAsync<T>(this IDbConnection dbConn, object anonType, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • T

SingleAsync<T>(IDbConnection, String, IEnumerable<IDbDataParameter>, CancellationToken)

Returns results from using a single name, value filter. E.g: <p>db.SingleAsync<Person>("Age = @age", new[] { db.CreateParam("age",42) })</p>

View Source
Declaration
public static Task<T> SingleAsync<T>(this IDbConnection dbConn, string sql, IEnumerable<IDbDataParameter> sqlParams, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
IEnumerable<IDbDataParameter>sqlParams
CancellationTokentoken
Type Parameters
  • T

SingleAsync<T>(IDbConnection, String, Object, CancellationToken)

Returns results from using a single name, value filter. E.g: <p>db.SingleAsync<Person>("Age = @age", new { age = 42 })</p>

View Source
Declaration
public static Task<T> SingleAsync<T>(this IDbConnection dbConn, string sql, object anonType = null, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • T

SingleByIdAsync<T>(IDbConnection, Object, CancellationToken)

Returns the first result using a primary key id. E.g: <p>db.SingleByIdAsync<Person>(1)</p>

View Source
Declaration
public static Task<T> SingleByIdAsync<T>(this IDbConnection dbConn, object idValue, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
System.ObjectidValue
CancellationTokentoken
Type Parameters
  • T

SingleWhereAsync<T>(IDbConnection, String, Object, CancellationToken)

Returns the first result using a name, value filter. E.g: <p>db.SingleWhereAsync<Person>("Age", 42)</p>

View Source
Declaration
public static Task<T> SingleWhereAsync<T>(this IDbConnection dbConn, string name, object value, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringname
System.Objectvalue
CancellationTokentoken
Type Parameters
  • T

ScalarAsync<T>(IDbCommand, String, IEnumerable<IDbDataParameter>)

View Source
Declaration
public static T ScalarAsync<T>(this IDbCommand dbCmd, string sql, IEnumerable<IDbDataParameter> sqlParams)
Returns

<T>

Parameters
TypeName
IDbCommanddbCmd
System.Stringsql
IEnumerable<IDbDataParameter>sqlParams
Type Parameters
  • T

ScalarAsync<T>(IDbConnection, ISqlExpression, CancellationToken)

Returns a single scalar value using an SqlExpression. E.g: <p>db.ScalarAsync<int>(db.From<Person>().Select(x => Sql.Count("*")).Where(q => q.Age > 40))</p>

View Source
Declaration
public static Task<T> ScalarAsync<T>(this IDbConnection dbConn, ISqlExpression sqlExpression, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
ServiceStack.OrmLite.ISqlExpressionsqlExpression
CancellationTokentoken
Type Parameters
  • T

ScalarAsync<T>(IDbConnection, String, IEnumerable<IDbDataParameter>, CancellationToken)

Returns a single scalar value using a parameterized query. E.g: <p>db.ScalarAsync<int>("SELECT COUNT(*) FROM Person WHERE Age > @age", new[] { db.CreateParam("age",40) })</p>

View Source
Declaration
public static Task<T> ScalarAsync<T>(this IDbConnection dbConn, string sql, IEnumerable<IDbDataParameter> sqlParams, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
IEnumerable<IDbDataParameter>sqlParams
CancellationTokentoken
Type Parameters
  • T

ScalarAsync<T>(IDbConnection, String, Object, CancellationToken)

Returns a single scalar value using a parameterized query. E.g: <p>db.ScalarAsync<int>("SELECT COUNT(*) FROM Person WHERE Age > @age", new { age = 40 })</p>

View Source
Declaration
public static Task<T> ScalarAsync<T>(this IDbConnection dbConn, string sql, object anonType = null, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • T

ColumnAsync<T>(IDbConnection, ISqlExpression, CancellationToken)

Returns the distinct first column values in a HashSet using an SqlExpression. E.g: <p>db.ColumnAsync<int>(db.From<Person>().Select(x => x.LastName).Where(q => q.Age == 27))</p>

View Source
Declaration
public static Task<List<T>> ColumnAsync<T>(this IDbConnection dbConn, ISqlExpression query, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
ServiceStack.OrmLite.ISqlExpressionquery
CancellationTokentoken
Type Parameters
  • T

ColumnAsync<T>(IDbConnection, String, IEnumerable<IDbDataParameter>, CancellationToken)

Returns the first column in a List using a SqlFormat query. E.g: <p>db.ColumnAsync<string>("SELECT LastName FROM Person WHERE Age = @age", new[] { db.CreateParam("age",27) })</p>

View Source
Declaration
public static Task<List<T>> ColumnAsync<T>(this IDbConnection dbConn, string sql, IEnumerable<IDbDataParameter> sqlParams, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
IEnumerable<IDbDataParameter>sqlParams
CancellationTokentoken
Type Parameters
  • T

ColumnAsync<T>(IDbConnection, String, Object, CancellationToken)

Returns the first column in a List using a SqlFormat query. E.g: <p>db.ColumnAsync<string>("SELECT LastName FROM Person WHERE Age = @age", new { age = 27 })</p>

View Source
Declaration
public static Task<List<T>> ColumnAsync<T>(this IDbConnection dbConn, string sql, object anonType = null, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • T

ColumnDistinctAsync<T>(IDbConnection, ISqlExpression, CancellationToken)

Returns the distinct first column values in a HashSet using an SqlExpression. E.g: <p>db.ColumnDistinctAsync<int>(db.From<Person>().Select(x => x.Age).Where(q => q.Age < 50))</p>

View Source
Declaration
public static Task<HashSet<T>> ColumnDistinctAsync<T>(this IDbConnection dbConn, ISqlExpression query, CancellationToken token = null)
Returns

Task<HashSet<<T>>>

Parameters
TypeName
IDbConnectiondbConn
ServiceStack.OrmLite.ISqlExpressionquery
CancellationTokentoken
Type Parameters
  • T

ColumnDistinctAsync<T>(IDbConnection, String, IEnumerable<IDbDataParameter>, CancellationToken)

Returns the distinct first column values in a HashSet using an SqlFormat query. E.g: <p>db.ColumnDistinctAsync<int>("SELECT Age FROM Person WHERE Age < @age", new[] { db.CreateParam("age",50) })</p>

View Source
Declaration
public static Task<HashSet<T>> ColumnDistinctAsync<T>(this IDbConnection dbConn, string sql, IEnumerable<IDbDataParameter> sqlParams, CancellationToken token = null)
Returns

Task<HashSet<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
IEnumerable<IDbDataParameter>sqlParams
CancellationTokentoken
Type Parameters
  • T

ColumnDistinctAsync<T>(IDbConnection, String, Object, CancellationToken)

Returns the distinct first column values in a HashSet using an SqlFormat query. E.g: <p>db.ColumnDistinctAsync<int>("SELECT Age FROM Person WHERE Age < @age", new { age = 50 })</p>

View Source
Declaration
public static Task<HashSet<T>> ColumnDistinctAsync<T>(this IDbConnection dbConn, string sql, object anonType = null, CancellationToken token = null)
Returns

Task<HashSet<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • T

LookupAsync<K, V>(IDbConnection, ISqlExpression, CancellationToken)

Returns an Dictionary<K, List<V>> grouping made from the first two columns using an Sql Expression. E.g: <p>db.LookupAsync<int, string>(db.From<Person>().Select(x => new { x.Age, x.LastName }).Where(q => q.Age < 50))</p>

View Source
Declaration
public static Task<Dictionary<K, List<V>>> LookupAsync<K, V>(this IDbConnection dbConn, ISqlExpression sqlExpression, CancellationToken token = null)
Returns

Task<Dictionary<<K>,List<<V>>>>

Parameters
TypeName
IDbConnectiondbConn
ServiceStack.OrmLite.ISqlExpressionsqlExpression
CancellationTokentoken
Type Parameters
  • K
  • V

LookupAsync<K, V>(IDbConnection, String, IEnumerable<IDbDataParameter>, CancellationToken)

Returns an Dictionary<K, List<V>> grouping made from the first two columns using an parameterized query. E.g: <p>db.LookupAsync<int, string>("SELECT Age, LastName FROM Person WHERE Age < @age", new[] { db.CreateParam("age",50) })</p>

View Source
Declaration
public static Task<Dictionary<K, List<V>>> LookupAsync<K, V>(this IDbConnection dbConn, string sql, IEnumerable<IDbDataParameter> sqlParams, CancellationToken token = null)
Returns

Task<Dictionary<<K>,List<<V>>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
IEnumerable<IDbDataParameter>sqlParams
CancellationTokentoken
Type Parameters
  • K
  • V

LookupAsync<K, V>(IDbConnection, String, Object, CancellationToken)

Returns an Dictionary<K, List<V>> grouping made from the first two columns using an parameterized query. E.g: <p>db.LookupAsync<int, string>("SELECT Age, LastName FROM Person WHERE Age < @age", new { age = 50 })</p>

View Source
Declaration
public static Task<Dictionary<K, List<V>>> LookupAsync<K, V>(this IDbConnection dbConn, string sql, object anonType = null, CancellationToken token = null)
Returns

Task<Dictionary<<K>,List<<V>>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • K
  • V

DictionaryAsync<K, V>(IDbConnection, ISqlExpression, CancellationToken)

Returns a Dictionary from the first 2 columns: Column 1 (Keys), Column 2 (Values) using an SqlExpression. E.g: <p>db.DictionaryAsync<int, string>(db.From<Person>().Select(x => new { x.Id, x.LastName }).Where(x => x.Age < 50))</p>

View Source
Declaration
public static Task<Dictionary<K, V>> DictionaryAsync<K, V>(this IDbConnection dbConn, ISqlExpression query, CancellationToken token = null)
Returns

Task<Dictionary<<K>,<V>>>

Parameters
TypeName
IDbConnectiondbConn
ServiceStack.OrmLite.ISqlExpressionquery
CancellationTokentoken
Type Parameters
  • K
  • V

DictionaryAsync<K, V>(IDbConnection, String, IEnumerable<IDbDataParameter>, CancellationToken)

Returns a Dictionary from the first 2 columns: Column 1 (Keys), Column 2 (Values) using sql. E.g: <p>db.DictionaryAsync<int, string>("SELECT Id, LastName FROM Person WHERE Age < @age", new[] { db.CreateParam("age",50) })</p>

View Source
Declaration
public static Task<Dictionary<K, V>> DictionaryAsync<K, V>(this IDbConnection dbConn, string sql, IEnumerable<IDbDataParameter> sqlParams, CancellationToken token = null)
Returns

Task<Dictionary<<K>,<V>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
IEnumerable<IDbDataParameter>sqlParams
CancellationTokentoken
Type Parameters
  • K
  • V

DictionaryAsync<K, V>(IDbConnection, String, Object, CancellationToken)

Returns a Dictionary from the first 2 columns: Column 1 (Keys), Column 2 (Values) using sql. E.g: <p>db.DictionaryAsync<int, string>("SELECT Id, LastName FROM Person WHERE Age < @age", new { age = 50 })</p>

View Source
Declaration
public static Task<Dictionary<K, V>> DictionaryAsync<K, V>(this IDbConnection dbConn, string sql, object anonType = null, CancellationToken token = null)
Returns

Task<Dictionary<<K>,<V>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • K
  • V

KeyValuePairsAsync<K, V>(IDbConnection, ISqlExpression, CancellationToken)

Returns a list of KeyValuePairs from the first 2 columns: Column 1 (Keys), Column 2 (Values) using an SqlExpression. E.g: <p>db.KeyValuePairsAsync<int, string>(db.From<Person>().Select(x => new { x.Id, x.LastName }).Where(x => x.Age < 50))</p>

View Source
Declaration
public static Task<List<KeyValuePair<K, V>>> KeyValuePairsAsync<K, V>(this IDbConnection dbConn, ISqlExpression query, CancellationToken token = null)
Returns

Task<List<KeyValuePair<<K>,<V>>>>

Parameters
TypeName
IDbConnectiondbConn
ServiceStack.OrmLite.ISqlExpressionquery
CancellationTokentoken
Type Parameters
  • K
  • V

KeyValuePairsAsync<K, V>(IDbConnection, String, IEnumerable<IDbDataParameter>, CancellationToken)

Returns a list of KeyValuePairs from the first 2 columns: Column 1 (Keys), Column 2 (Values) using sql. E.g: <p>db.KeyValuePairsAsync<int, string>("SELECT Id, LastName FROM Person WHERE Age < @age", new[] { db.CreateParam("age",50) })</p>

View Source
Declaration
public static Task<List<KeyValuePair<K, V>>> KeyValuePairsAsync<K, V>(this IDbConnection dbConn, string sql, IEnumerable<IDbDataParameter> sqlParams, CancellationToken token = null)
Returns

Task<List<KeyValuePair<<K>,<V>>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
IEnumerable<IDbDataParameter>sqlParams
CancellationTokentoken
Type Parameters
  • K
  • V

KeyValuePairsAsync<K, V>(IDbConnection, String, Object, CancellationToken)

Returns a list of KeyValuePairs from the first 2 columns: Column 1 (Keys), Column 2 (Values) using sql. E.g: <p>db.KeyValuePairsAsync<int, string>("SELECT Id, LastName FROM Person WHERE Age < @age", new { age = 50 })</p>

View Source
Declaration
public static Task<List<KeyValuePair<K, V>>> KeyValuePairsAsync<K, V>(this IDbConnection dbConn, string sql, object anonType = null, CancellationToken token = null)
Returns

Task<List<KeyValuePair<<K>,<V>>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • K
  • V

ExistsAsync<T>(IDbConnection, Expression<Func<T, Boolean>>, CancellationToken)

Returns true if the Query returns any records that match the LINQ expression, E.g: <p>db.ExistsAsync<Person>(x => x.Age < 50)</p>

View Source
Declaration
public static Task<bool> ExistsAsync<T>(this IDbConnection dbConn, Expression<Func<T, bool>> expression, CancellationToken token = null)
Returns

Task<System.Boolean>

Parameters
TypeName
IDbConnectiondbConn
Expression<Func<<T>,System.Boolean>>expression
CancellationTokentoken
Type Parameters
  • T

ExistsAsync<T>(IDbConnection, SqlExpression<T>, CancellationToken)

Returns true if the Query returns any records that match the supplied SqlExpression, E.g: <p>db.ExistsAsync(db.From<Person>().Where(x => x.Age < 50))</p>

View Source
Declaration
public static Task<bool> ExistsAsync<T>(this IDbConnection dbConn, SqlExpression<T> expression, CancellationToken token = null)
Returns

Task<System.Boolean>

Parameters
TypeName
IDbConnectiondbConn
ServiceStack.OrmLite.SqlExpression<T>expression
CancellationTokentoken
Type Parameters
  • T

ExistsAsync<T>(IDbConnection, Object, CancellationToken)

Returns true if the Query returns any records, using an SqlFormat query. E.g: <p>db.ExistsAsync<Person>(new { Age = 42 })</p>

View Source
Declaration
public static Task<bool> ExistsAsync<T>(this IDbConnection dbConn, object anonType, CancellationToken token = null)
Returns

Task<System.Boolean>

Parameters
TypeName
IDbConnectiondbConn
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • T

ExistsAsync<T>(IDbConnection, String, Object, CancellationToken)

Returns true if the Query returns any records, using a parameterized query. E.g: <p>db.ExistsAsync<Person>("Age = @age", new { age = 42 })</p> <p>db.ExistsAsync<Person>("SELECT * FROM Person WHERE Age = @age", new { age = 42 })</p>

View Source
Declaration
public static Task<bool> ExistsAsync<T>(this IDbConnection dbConn, string sql, object anonType = null, CancellationToken token = null)
Returns

Task<System.Boolean>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • T

SqlListAsync<T>(IDbConnection, ISqlExpression, CancellationToken)

Returns results from an arbitrary SqlExpression. E.g: <p>db.SqlListAsync<Person>(db.From<Person>().Select("*").Where(q => q.Age < 50))</p>

View Source
Declaration
public static Task<List<T>> SqlListAsync<T>(this IDbConnection dbConn, ISqlExpression sqlExpression, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
ServiceStack.OrmLite.ISqlExpressionsqlExpression
CancellationTokentoken
Type Parameters
  • T

SqlListAsync<T>(IDbConnection, String, IEnumerable<IDbDataParameter>, CancellationToken)

Returns results from an arbitrary parameterized raw sql query. E.g: <p>db.SqlListAsync<Person>("EXEC GetRockstarsAged @age", new { age = 50 })</p>

View Source
Declaration
public static Task<List<T>> SqlListAsync<T>(this IDbConnection dbConn, string sql, IEnumerable<IDbDataParameter> sqlParams, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
IEnumerable<IDbDataParameter>sqlParams
CancellationTokentoken
Type Parameters
  • T

SqlListAsync<T>(IDbConnection, String, Object, CancellationToken)

Returns results from an arbitrary parameterized raw sql query. E.g: <p>db.SqlListAsync<Person>("EXEC GetRockstarsAged @age", new { age = 50 })</p>

View Source
Declaration
public static Task<List<T>> SqlListAsync<T>(this IDbConnection dbConn, string sql, object anonType = null, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • T

SqlListAsync<T>(IDbConnection, String, Dictionary<String, Object>, CancellationToken)

Returns results from an arbitrary parameterized raw sql query. E.g: <p>db.SqlListAsync<Person>("EXEC GetRockstarsAged @age", new Dictionary<string, object> { { "age", 42 } })</p>

View Source
Declaration
public static Task<List<T>> SqlListAsync<T>(this IDbConnection dbConn, string sql, Dictionary<string, object> dict, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
Dictionary<System.String,System.Object>dict
CancellationTokentoken
Type Parameters
  • T

SqlListAsync<T>(IDbConnection, String, Action<IDbCommand>, CancellationToken)

Returns results from an arbitrary parameterized raw sql query with a dbCmd filter. E.g: <p>db.SqlListAsync<Person>("EXEC GetRockstarsAged @age", dbCmd => ...)</p>

View Source
Declaration
public static Task<List<T>> SqlListAsync<T>(this IDbConnection dbConn, string sql, Action<IDbCommand> dbCmdFilter, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
Action<IDbCommand>dbCmdFilter
CancellationTokentoken
Type Parameters
  • T

SqlColumnAsync<T>(IDbConnection, ISqlExpression, CancellationToken)

Returns the first column in a List using an SqlExpression. E.g: <p>db.SqlColumnAsync<string>(db.From<Person>().Select(x => x.LastName).Where(q => q.Age < 50))</p>

View Source
Declaration
public static Task<List<T>> SqlColumnAsync<T>(this IDbConnection dbConn, ISqlExpression sqlExpression, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
ServiceStack.OrmLite.ISqlExpressionsqlExpression
CancellationTokentoken
Type Parameters
  • T

SqlColumnAsync<T>(IDbConnection, String, IEnumerable<IDbDataParameter>, CancellationToken)

Returns the first column in a List using a parameterized query. E.g: <p>db.SqlColumnAsync<string>("SELECT LastName FROM Person WHERE Age < @age", new[] { db.CreateParam("age",50) })</p>

View Source
Declaration
public static Task<List<T>> SqlColumnAsync<T>(this IDbConnection dbConn, string sql, IEnumerable<IDbDataParameter> sqlParams, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
IEnumerable<IDbDataParameter>sqlParams
CancellationTokentoken
Type Parameters
  • T

SqlColumnAsync<T>(IDbConnection, String, Object, CancellationToken)

Returns the first column in a List using a parameterized query. E.g: <p>db.SqlColumnAsync<string>("SELECT LastName FROM Person WHERE Age < @age", new { age = 50 })</p>

View Source
Declaration
public static Task<List<T>> SqlColumnAsync<T>(this IDbConnection dbConn, string sql, object anonType = null, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • T

SqlColumnAsync<T>(IDbConnection, String, Dictionary<String, Object>, CancellationToken)

Returns the first column in a List using a parameterized query. E.g: <p>db.SqlColumnAsync<string>("SELECT LastName FROM Person WHERE Age < @age", new Dictionary<string, object> { { "age", 50 } })</p>

View Source
Declaration
public static Task<List<T>> SqlColumnAsync<T>(this IDbConnection dbConn, string sql, Dictionary<string, object> dict, CancellationToken token = null)
Returns

Task<List<<T>>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
Dictionary<System.String,System.Object>dict
CancellationTokentoken
Type Parameters
  • T

SqlScalarAsync<T>(IDbConnection, ISqlExpression, CancellationToken)

Returns a single Scalar value using an SqlExpression. E.g: <p>db.SqlScalarAsync<int>(db.From<Person>().Select(Sql.Count("*")).Where(q => q.Age < 50))</p>

View Source
Declaration
public static Task<T> SqlScalarAsync<T>(this IDbConnection dbConn, ISqlExpression sqlExpression, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
ServiceStack.OrmLite.ISqlExpressionsqlExpression
CancellationTokentoken
Type Parameters
  • T

SqlScalarAsync<T>(IDbConnection, String, IEnumerable<IDbDataParameter>, CancellationToken)

Returns a single Scalar value using a parameterized query. E.g: <p>db.SqlScalarAsync<int>("SELECT COUNT(*) FROM Person WHERE Age < @age", new[] { db.CreateParam("age",50) })</p>

View Source
Declaration
public static Task<T> SqlScalarAsync<T>(this IDbConnection dbConn, string sql, IEnumerable<IDbDataParameter> sqlParams, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
IEnumerable<IDbDataParameter>sqlParams
CancellationTokentoken
Type Parameters
  • T

SqlScalarAsync<T>(IDbConnection, String, Object, CancellationToken)

Returns a single Scalar value using a parameterized query. E.g: <p>db.SqlScalarAsync<int>("SELECT COUNT(*) FROM Person WHERE Age < @age", new { age = 50 })</p>

View Source
Declaration
public static Task<T> SqlScalarAsync<T>(this IDbConnection dbConn, string sql, object anonType = null, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • T

SqlScalarAsync<T>(IDbConnection, String, Dictionary<String, Object>, CancellationToken)

Returns a single Scalar value using a parameterized query. E.g: <p>db.SqlScalarAsync<int>("SELECT COUNT(*) FROM Person WHERE Age < @age", new Dictionary<string, object> { { "age", 50 } })</p>

View Source
Declaration
public static Task<T> SqlScalarAsync<T>(this IDbConnection dbConn, string sql, Dictionary<string, object> dict, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
Dictionary<System.String,System.Object>dict
CancellationTokentoken
Type Parameters
  • T

ExecuteNonQueryAsync(IDbConnection, String, CancellationToken)

Executes a raw sql non-query using sql. E.g: <p>var rowsAffected = db.ExecuteNonQueryAsync("UPDATE Person SET LastName={0} WHERE Id={1}".SqlFormat("WaterHouse", 7))</p>

View Source
Declaration
public static Task<int> ExecuteNonQueryAsync(this IDbConnection dbConn, string sql, CancellationToken token = null)
Returns

Task<System.Int32>: number of rows affected

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
CancellationTokentoken

ExecuteNonQueryAsync(IDbConnection, String, Object, CancellationToken)

Executes a raw sql non-query using a parameterized query. E.g: <p>var rowsAffected = db.ExecuteNonQueryAsync("UPDATE Person SET LastName=@name WHERE Id=@id", new { name = "WaterHouse", id = 7 })</p>

View Source
Declaration
public static Task<int> ExecuteNonQueryAsync(this IDbConnection dbConn, string sql, object anonType, CancellationToken token = null)
Returns

Task<System.Int32>: number of rows affected

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
System.ObjectanonType
CancellationTokentoken

ExecuteNonQueryAsync(IDbConnection, String, Dictionary<String, Object>, CancellationToken)

Executes a raw sql non-query using a parameterized query.

View Source
Declaration
public static Task<int> ExecuteNonQueryAsync(this IDbConnection dbConn, string sql, Dictionary<string, object> dict, CancellationToken token = null)
Returns

Task<System.Int32>: number of rows affected

Parameters
TypeName
IDbConnectiondbConn
System.Stringsql
Dictionary<System.String,System.Object>dict
CancellationTokentoken

SqlProcedureAsync<TOutputModel>(IDbConnection, Object, CancellationToken)

Returns results from a Stored Procedure, using a parameterized query.

View Source
Declaration
public static Task<List<TOutputModel>> SqlProcedureAsync<TOutputModel>(this IDbConnection dbConn, object anonType, CancellationToken token = null)
Returns

Task<List<<TOutputModel>>>

Parameters
TypeName
IDbConnectiondbConn
System.ObjectanonType
CancellationTokentoken
Type Parameters
  • TOutputModel

LongScalarAsync(IDbConnection, CancellationToken)

Returns the scalar result as a long.

View Source
Declaration
public static Task<long> LongScalarAsync(this IDbConnection dbConn, CancellationToken token = null)
Returns

Task<System.Int64>

Parameters
TypeName
IDbConnectiondbConn
CancellationTokentoken

LoadSingleByIdAsync<T>(IDbConnection, Object, String[], CancellationToken)

Returns the first result with all its references loaded, using a primary key id. E.g: <p>db.LoadSingleByIdAsync<Person>(1)</p>

View Source
Declaration
public static Task<T> LoadSingleByIdAsync<T>(this IDbConnection dbConn, object idValue, string[] include = null, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
System.ObjectidValue
System.String[]include
CancellationTokentoken
Type Parameters
  • T

LoadSingleByIdAsync<T>(IDbConnection, Object, Expression<Func<T, Object>>, CancellationToken)

Returns the first result with all its references loaded, using a primary key id. E.g: <p>db.LoadSingleByIdAsync<Person>(1, include = x => new { x.Address })</p>

View Source
Declaration
public static Task<T> LoadSingleByIdAsync<T>(this IDbConnection dbConn, object idValue, Expression<Func<T, object>> include, CancellationToken token = null)
Returns

Task<<T>>

Parameters
TypeName
IDbConnectiondbConn
System.ObjectidValue
Expression<Func<<T>,System.Object>>include
CancellationTokentoken
Type Parameters
  • T

LoadReferencesAsync<T>(IDbConnection, T, String[], CancellationToken)

Loads all the related references onto the instance. E.g: <p>db.LoadReferencesAsync(customer)</p>

View Source
Declaration
public static Task LoadReferencesAsync<T>(this IDbConnection dbConn, T instance, string[] include = null, CancellationToken token = null)
Returns

Task

Parameters
TypeName
IDbConnectiondbConn
<T>instance
System.String[]include
CancellationTokentoken
Type Parameters
  • T