mirror of
https://github.com/bitwarden/server.git
synced 2025-04-06 21:48:12 -05:00
always specify DateTimeKind.Utc for dapper
This commit is contained in:
parent
4dbea821a4
commit
ffa0a1a02c
@ -1,9 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Dapper;
|
||||||
|
|
||||||
namespace Bit.Core.Repositories.SqlServer
|
namespace Bit.Core.Repositories.SqlServer
|
||||||
{
|
{
|
||||||
public abstract class BaseRepository
|
public abstract class BaseRepository
|
||||||
{
|
{
|
||||||
|
static BaseRepository()
|
||||||
|
{
|
||||||
|
SqlMapper.AddTypeHandler(new DateTimeHandler());
|
||||||
|
}
|
||||||
|
|
||||||
public BaseRepository(string connectionString)
|
public BaseRepository(string connectionString)
|
||||||
{
|
{
|
||||||
if(string.IsNullOrWhiteSpace(connectionString))
|
if(string.IsNullOrWhiteSpace(connectionString))
|
||||||
|
16
src/Core/Repositories/SqlServer/DateTimeHandler.cs
Normal file
16
src/Core/Repositories/SqlServer/DateTimeHandler.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using Dapper;
|
||||||
|
|
||||||
|
public class DateTimeHandler : SqlMapper.TypeHandler<DateTime>
|
||||||
|
{
|
||||||
|
public override void SetValue(IDbDataParameter parameter, DateTime value)
|
||||||
|
{
|
||||||
|
parameter.Value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override DateTime Parse(object value)
|
||||||
|
{
|
||||||
|
return DateTime.SpecifyKind((DateTime)value, DateTimeKind.Utc);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user