-
Notifications
You must be signed in to change notification settings - Fork 4
Extension method reference
##Overview
The extension methods SimpleLoad adds to IDbConnection provide the interface to retrieve data from your database.
Note that at present the only supported RDBMS is SQL Server. Dapper.SimpleLoad should work with SQL Server 2005 and later, including SQL Server 2016 CTP 3.2.
##Mapping to objects using fully automated query generation
SimpleLoad provides the following extension methods for loading objects using fully automated querying:
public static IList<T1> AutoQuery<T1>(
this IDbConnection connection, object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2>(
this IDbConnection connection, object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2, T3>(
this IDbConnection connection, object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2, T3, T4>(
this IDbConnection connection, object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2, T3, T4, T5>(
this IDbConnection connection, object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2, T3, T4, T5, T6>(
this IDbConnection connection, object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2, T3, T4, T5, T6, T7>(
this IDbConnection connection, object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2, T3, T4, T5, T6, T7, T8>(
this IDbConnection connection, object parameters, int desiredNumberOfResults = 0)
Alternatively, for those scenarios where you need AutoQuery to build a POCO hierarchy involving more than eight different types, you can use:
public static IList<T1> AutoQuery<T1>(
this IDbConnection connection, Type[] additionalTypes,
object parameters, int desiredNumberOfResults = 0)
TODO: how to use these - it's mostly an explanation of how SimpleLoad uses the list of types to build a query. This is really something for the tutorial.
##Mapping to objects using a query with a custom WHERE clause
To query using a custom WHERE clause, useful when you need conditions in the WHERE clause that aren't on the top level table, use one of the following methods:
public static IList<T1> AutoQuery<T1>(
this IDbConnection connection, string [] tableAliases, string whereClauseExpression,
object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2>(
this IDbConnection connection, string [] tableAliases, string whereClauseExpression,
object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2, T3>(
this IDbConnection connection, string [] tableAliases, string whereClauseExpression,
object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2, T3, T4>(
this IDbConnection connection, string [] tableAliases, string whereClauseExpression,
object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2, T3, T4, T5>(
this IDbConnection connection, string [] tableAliases, string whereClauseExpression,
object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2, T3, T4, T5, T6>(
this IDbConnection connection, string [] tableAliases, string whereClauseExpression,
object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2, T3, T4, T5, T6, T7>(
this IDbConnection connection, string [] tableAliases, string whereClauseExpression,
object parameters, int desiredNumberOfResults = 0)
public static IList<T1> AutoQuery<T1, T2, T3, T4, T5, T6, T7, T8>(
this IDbConnection connection, string [] tableAliases, string whereClauseExpression,
object parameters, int desiredNumberOfResults = 0)
Again, if you need to map onto more than eight DAO types we provide a method you can use:
public static IList<T1> AutoQuery<T1>(
this IDbConnection connection, Type[] additionalTypes, string [] tableAliases,
string whereClauseExpression, object parameters, int desiredNumberOfResults = 0)
Sometimes you need to break out a full custom SQL query to map to your objects. In that case you'll want to use one of these methods:
public static IList<T1> CustomQuery<T1>(
this IDbConnection connection, string completeParameterisedSqlQuery,
object parameters)
public static IList<T1> CustomQuery<T1, T2>(
this IDbConnection connection, string completeParameterisedSqlQuery,
object parameters, string splitOn)
public static IList<T1> CustomQuery<T1, T2, T3>(
this IDbConnection connection, string completeParameterisedSqlQuery,
object parameters, string splitOn)
public static IList<T1> CustomQuery<T1, T2, T3, T4>(
this IDbConnection connection, string completeParameterisedSqlQuery,
object parameters, string splitOn)
public static IList<T1> CustomQuery<T1, T2, T3, T4, T5>(
this IDbConnection connection, string completeParameterisedSqlQuery,
object parameters, string splitOn)
public static IList<T1> CustomQuery<T1, T2, T3, T4, T5, T6>(
this IDbConnection connection, string completeParameterisedSqlQuery,
object parameters, string splitOn)
public static IList<T1> CustomQuery<T1, T2, T3, T4, T5, T6, T7>(
this IDbConnection connection, string completeParameterisedSqlQuery,
object parameters, string splitOn)
public static IList<T1> CustomQuery<T1, T2, T3, T4, T5, T6, T7, T8>(
this IDbConnection connection, string completeParameterisedSqlQuery,
object parameters, string splitOn)
As per the other query options, we provide a method allowing you to map to more than eight types of object:
public static IList<T1> CustomQuery<T1>(
this IDbConnection connection, Type [] additionalTypes, string completeParameterisedSqlQuery, object parameters, string splitOn = null)