-
Notifications
You must be signed in to change notification settings - Fork 874
Expand file tree
/
Copy pathNpgsqlNodaTimeExtensions.cs
More file actions
32 lines (29 loc) · 1.14 KB
/
NpgsqlNodaTimeExtensions.cs
File metadata and controls
32 lines (29 loc) · 1.14 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
using Npgsql.NodaTime.Internal;
using Npgsql.TypeMapping;
// ReSharper disable once CheckNamespace
namespace Npgsql;
/// <summary>
/// Extension adding the NodaTime plugin to an Npgsql type mapper.
/// </summary>
public static class NpgsqlNodaTimeExtensions
{
// Note: defined for binary compatibility and NpgsqlConnection.GlobalTypeMapper.
/// <summary>
/// Sets up NodaTime mappings for the PostgreSQL date/time types.
/// </summary>
/// <param name="mapper">The type mapper to set up (global or connection-specific)</param>
public static INpgsqlTypeMapper UseNodaTime(this INpgsqlTypeMapper mapper)
{
mapper.AddTypeInfoResolverFactory(new NodaTimeTypeInfoResolverFactory());
return mapper;
}
/// <summary>
/// Sets up NodaTime mappings for the PostgreSQL date/time types.
/// </summary>
/// <param name="mapper">The type mapper to set up (global or connection-specific)</param>
public static TMapper UseNodaTime<TMapper>(this TMapper mapper) where TMapper : INpgsqlTypeMapper
{
mapper.AddTypeInfoResolverFactory(new NodaTimeTypeInfoResolverFactory());
return mapper;
}
}