Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TimeOnly Converter & Comparer for Entity FrameworkCore 6.0
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