-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFlexQueryDapperExtensions.cs
More file actions
53 lines (45 loc) · 1.5 KB
/
FlexQueryDapperExtensions.cs
File metadata and controls
53 lines (45 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using Microsoft.Extensions.DependencyInjection;
using FlexQuery.NET.Dapper.Sql;
namespace FlexQuery.NET.Dapper.Configuration;
public static class FlexQueryDapperExtensions
{
/// <summary>
/// Configures FlexQuery.NET Dapper globally.
/// </summary>
public static IServiceCollection AddFlexQueryDapper(this IServiceCollection services, Action<DapperQueryOptions> configure)
{
var options = new DapperQueryOptions();
configure(options);
// Optionally, register the options as a singleton or configured options
services.AddSingleton(options);
if (options.Dialect != null)
{
DapperQueryOptions.GlobalDefaultDialect = options.Dialect;
}
return services;
}
/// <summary>
/// Configures the SQL Server dialect.
/// </summary>
public static DapperQueryOptions UseSqlServer(this DapperQueryOptions options)
{
options.Dialect = new Dialects.SqlServerDialect();
return options;
}
/// <summary>
/// Configures the PostgreSQL dialect.
/// </summary>
public static DapperQueryOptions UsePostgreSql(this DapperQueryOptions options)
{
options.Dialect = new Dialects.PostgreSqlDialect();
return options;
}
/// <summary>
/// Configures the SQLite dialect.
/// </summary>
public static DapperQueryOptions UseSqlite(this DapperQueryOptions options)
{
options.Dialect = new Dialects.SqliteDialect();
return options;
}
}