| | | 1 | | using Microsoft.EntityFrameworkCore.Metadata.Builders; |
| | | 2 | | using ZhEaIsNsAaBn.Infrastructure.Core; |
| | | 3 | | |
| | | 4 | | // ReSharper disable once CheckNamespace |
| | | 5 | | namespace Microsoft.EntityFrameworkCore; |
| | | 6 | | |
| | | 7 | | /// <summary>Property-builder shortcuts that store a <see cref="HijriDate"/> as Hijri text, with a column of the matchin |
| | | 8 | | public static class EfValueConverterExtensions |
| | | 9 | | { |
| | | 10 | | /// <summary>Required Hijri date column: <c>yyyy-MM-dd</c> as Unicode text of 10 (<see cref="HijriDateOnlyConverter" |
| | | 11 | | /// <typeparam name="TProperty">The property type.</typeparam> |
| | | 12 | | /// <param name="propertyBuilder">The property builder.</param> |
| | | 13 | | /// <returns>The same builder.</returns> |
| | | 14 | | public static PropertyBuilder<TProperty> AsHijriDate< TProperty >( this PropertyBuilder<TProperty> propertyBuilder ) |
| | 40 | 15 | | => Configure<TProperty, HijriDateOnlyConverter>( propertyBuilder, required: true, HijriText.DateLength ); |
| | | 16 | | |
| | | 17 | | /// <summary>Same as <see cref="AsHijriDate{TProperty}"/>.</summary> |
| | | 18 | | /// <typeparam name="TProperty">The property type.</typeparam> |
| | | 19 | | /// <param name="propertyBuilder">The property builder.</param> |
| | | 20 | | /// <returns>The same builder.</returns> |
| | 0 | 21 | | public static PropertyBuilder<TProperty> AsHijriDateOnly< TProperty >( this PropertyBuilder<TProperty> propertyBuild |
| | | 22 | | |
| | | 23 | | /// <summary>Required Hijri date-and-time column: 24-hour <c>yyyy-MM-dd HH:mm:ss</c> as Unicode text of 19 (<see cre |
| | | 24 | | /// <typeparam name="TProperty">The property type.</typeparam> |
| | | 25 | | /// <param name="propertyBuilder">The property builder.</param> |
| | | 26 | | /// <returns>The same builder.</returns> |
| | | 27 | | public static PropertyBuilder<TProperty> AsHijriDateTime< TProperty >( this PropertyBuilder<TProperty> propertyBuild |
| | 24 | 28 | | => Configure<TProperty, HijriDateConverter>( propertyBuilder, required: true, HijriText.DateTimeLength ); |
| | | 29 | | |
| | | 30 | | /// <summary>Optional Hijri date column: <c>yyyy-MM-dd</c> as Unicode text of 10 (<see cref="NullableHijriDateOnlyCo |
| | | 31 | | /// <typeparam name="TProperty">The property type.</typeparam> |
| | | 32 | | /// <param name="propertyBuilder">The property builder.</param> |
| | | 33 | | /// <returns>The same builder.</returns> |
| | | 34 | | public static PropertyBuilder<TProperty> AsNullableHijriDate< TProperty >( this PropertyBuilder<TProperty> propertyB |
| | 0 | 35 | | => Configure<TProperty, NullableHijriDateOnlyConverter>( propertyBuilder, required: false, HijriText.DateLength |
| | | 36 | | |
| | | 37 | | /// <summary>Same as <see cref="AsNullableHijriDate{TProperty}"/>.</summary> |
| | | 38 | | /// <typeparam name="TProperty">The property type.</typeparam> |
| | | 39 | | /// <param name="propertyBuilder">The property builder.</param> |
| | | 40 | | /// <returns>The same builder.</returns> |
| | 0 | 41 | | public static PropertyBuilder<TProperty> AsNullableHijriDateOnly< TProperty >( this PropertyBuilder<TProperty> prope |
| | | 42 | | |
| | | 43 | | /// <summary>Optional Hijri date-and-time column: 24-hour <c>yyyy-MM-dd HH:mm:ss</c> as Unicode text of 19 (<see cre |
| | | 44 | | /// <typeparam name="TProperty">The property type.</typeparam> |
| | | 45 | | /// <param name="propertyBuilder">The property builder.</param> |
| | | 46 | | /// <returns>The same builder.</returns> |
| | | 47 | | public static PropertyBuilder<TProperty> AsNullableHijriDateTime< TProperty >( this PropertyBuilder<TProperty> prope |
| | 40 | 48 | | => Configure<TProperty, NullableHijriDateConverter>( propertyBuilder, required: false, HijriText.DateTimeLength |
| | | 49 | | |
| | | 50 | | |
| | | 51 | | private static PropertyBuilder<TProperty> Configure< TProperty, TConverter >( PropertyBuilder<TProperty> propertyBui |
| | | 52 | | where TConverter : ValueConverter |
| | | 53 | | { |
| | 104 | 54 | | ArgumentNullException.ThrowIfNull( propertyBuilder ); |
| | | 55 | | |
| | | 56 | | // Unicode text of the given length; the provider picks the column type. |
| | 104 | 57 | | return propertyBuilder.IsRequired( required ).HasMaxLength( length ).IsUnicode().HasConversion<TConverter>(); |
| | | 58 | | } |
| | | 59 | | } |