diff --git a/RhSolutions.Api/Models/RhsolutionsContext.cs b/RhSolutions.Api/Models/RhsolutionsContext.cs index e9df2eb..be0fcb5 100644 --- a/RhSolutions.Api/Models/RhsolutionsContext.cs +++ b/RhSolutions.Api/Models/RhsolutionsContext.cs @@ -14,8 +14,9 @@ public class RhSolutionsContext : DbContext builder.Entity() .Property(e => e.ProductSku) .HasConversion(v => v.ToString(), v => new ProductSku(v)); - // builder.Entity() - // .Property(e => e.DeprecatedSkus) - // .HasPostgresArrayConversion(v => v.ToString(), v => new ProductSku(v)); + builder.Entity() + .PrimitiveCollection(e => e.DeprecatedSkus) + .ElementType() + .HasConversion(typeof(SkuConverter)); } } diff --git a/RhSolutions.Api/Models/SkuConverter.cs b/RhSolutions.Api/Models/SkuConverter.cs new file mode 100644 index 0000000..c66d851 --- /dev/null +++ b/RhSolutions.Api/Models/SkuConverter.cs @@ -0,0 +1,11 @@ +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace RhSolutions.Models; + +internal class SkuConverter : ValueConverter +{ + public SkuConverter() + : base(x => x.ToString(), x => new ProductSku(x)) + { + } +}