| | | 1 | | using Microsoft.Extensions.DependencyInjection; |
| | | 2 | | |
| | | 3 | | namespace ArturRios.Data.Dapper; |
| | | 4 | | |
| | | 5 | | /// <summary>DI registration for the Dapper query path.</summary> |
| | | 6 | | public static class ServiceCollectionExtensions |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Registers <see cref="ISqlQuery" /> and <see cref="IAsyncSqlQuery" /> (scoped, backed by |
| | | 10 | | /// <see cref="DapperSqlQuery" />). Requires a <c>BaseDbContext</c> to be registered |
| | | 11 | | /// (e.g. via <c>AddDataConfigFromSettings<TContext></c>). |
| | | 12 | | /// Query failures are logged in full when logging is registered (<c>AddLogging</c>); |
| | | 13 | | /// without it the executor still runs and error envelopes carry no provider text. |
| | | 14 | | /// </summary> |
| | | 15 | | /// <param name="services">The service collection.</param> |
| | | 16 | | public static IServiceCollection AddDapper(this IServiceCollection services) |
| | | 17 | | { |
| | 4 | 18 | | services.AddScoped<ISqlQuery, DapperSqlQuery>(); |
| | 4 | 19 | | services.AddScoped<IAsyncSqlQuery, DapperSqlQuery>(); |
| | | 20 | | |
| | 4 | 21 | | return services; |
| | | 22 | | } |
| | | 23 | | } |