SqlMapper class
namespace: Serenity.Data assembly: Serenity.Net.Services
Provides IDbConnection extension methods that wrap the corresponding Dapper SqlMapper methods, translating Serenity SQL (dialect specific brackets and parameter prefixes) via Translate and ensuring the connection is open before execution. It mirrors the string based Execute and Query extension methods of Dapper's SqlMapper, not every Dapper overload (CommandDefinition based methods, ExecuteScalar, ExecuteReader, QueryFirst, QueryMultiple, etc.), as well as their async variants. The ISqlQuery overloads are Serenity specific and have no Dapper equivalent. Note that unlike SqlHelper methods, these extension methods do not go through ISqlOperationInterceptor. Transaction handling: an explicitly passed transaction takes precedence; when it is null the connection's ambient transaction applies. That works because the connection (usually a WrappedConnection) enlists the ambient transaction at command creation, and Dapper only overwrites it with a non-null transaction argument. An explicit Dapper commandTimeout takes precedence; when it is omitted, WrappedConnection applies its configured timeout or DefaultCommandTimeout when creating the command. Serenity query parameter names retain the @ prefix while SQL text is translated to the connection dialect. Dapper strips parameter prefixes when matching names, so query parameters such as @Id bind correctly to Oracle SQL using :Id.
public static class SqlMapper
Public Members
| name | description |
|---|---|
| static Execute(…) | Executes a parameterized SQL statement. |
| static ExecuteAsync(…) | Executes a parameterized SQL statement asynchronously. |
| static Query(…) | Returns a list of dynamic objects; the reader is closed after the call. (2 methods) |
| static Query<T>(…) | Returns a list of objects; the reader is closed after the call. (2 methods) |
| static QueryAsync(…) | Returns a list of dynamic objects asynchronously; the reader is closed after the call. (2 methods) |
| static QueryAsync<T>(…) | Returns a list of objects asynchronously; the reader is closed after the call. (2 methods) |
See Also
- Source: DapperCore.cs