Created
January 7, 2022 15:10
-
-
Save marcominerva/773768729082febd50937f6f650daa27 to your computer and use it in GitHub Desktop.
TimeOnly Converter & Comparer for Entity FrameworkCore 6.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TimeOnlyConverter : ValueConverter<TimeOnly, TimeSpan> | |
{ | |
public TimeOnlyConverter() : base( | |
timeOnly => timeOnly.ToTimeSpan(), | |
timeSpan => TimeOnly.FromTimeSpan(timeSpan)) | |
{ | |
} | |
} | |
public class TimeOnlyComparer : ValueComparer<TimeOnly> | |
{ | |
public TimeOnlyComparer() : base( | |
(t1, t2) => t1.Ticks == t2.Ticks, | |
t => t.GetHashCode()) | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment