16 lines
486 B
C#
16 lines
486 B
C#
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using System;
|
|
|
|
namespace _0_Framework.InfraStructure;
|
|
|
|
public static class PropertyBuilderExtensions
|
|
{
|
|
public static PropertyBuilder<TimeSpan> HasTimeSpanConversion(this PropertyBuilder<TimeSpan> builder)
|
|
{
|
|
return builder.HasConversion(
|
|
v => v == TimeSpan.Zero ? "" : v.ToString(),
|
|
v => string.IsNullOrWhiteSpace(v) ? TimeSpan.Zero : TimeSpan.Parse(v)
|
|
).HasMaxLength(30);
|
|
}
|
|
|
|
} |