32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace gehGassiApp.Data.Converter
|
|
{
|
|
public class DateTimeOffsetToUtcDateTimeTicksConverter : ValueConverter<DateTimeOffset, long>
|
|
{
|
|
/// <summary>
|
|
/// Creates a new instance of this converter.
|
|
/// </summary>
|
|
/// <param name="mappingHints">
|
|
/// </param>
|
|
public DateTimeOffsetToUtcDateTimeTicksConverter(ConverterMappingHints? mappingHints = null)
|
|
: base(
|
|
v => v.UtcDateTime.Ticks,
|
|
v => new DateTimeOffset(v, new TimeSpan(0, 0, 0)),
|
|
mappingHints)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// A <see cref="ValueConverterInfo" /> for the default use of this converter.
|
|
/// </summary>
|
|
public static ValueConverterInfo DefaultInfo { get; }
|
|
= new(typeof(DateTimeOffset), typeof(long), i => new DateTimeOffsetToUtcDateTimeTicksConverter(i.MappingHints));
|
|
}
|
|
}
|