Add actual postgresql type conversions
This commit is contained in:
parent
2d188d7657
commit
c8bf31ab50
@ -14,8 +14,9 @@ public class RhSolutionsContext : DbContext
|
||||
builder.Entity<Product>()
|
||||
.Property(e => e.ProductSku)
|
||||
.HasConversion(v => v.ToString(), v => new ProductSku(v));
|
||||
// builder.Entity<Product>()
|
||||
// .Property(e => e.DeprecatedSkus)
|
||||
// .HasPostgresArrayConversion<ProductSku, string>(v => v.ToString(), v => new ProductSku(v));
|
||||
builder.Entity<Product>()
|
||||
.PrimitiveCollection(e => e.DeprecatedSkus)
|
||||
.ElementType()
|
||||
.HasConversion(typeof(SkuConverter));
|
||||
}
|
||||
}
|
||||
|
11
RhSolutions.Api/Models/SkuConverter.cs
Normal file
11
RhSolutions.Api/Models/SkuConverter.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace RhSolutions.Models;
|
||||
|
||||
internal class SkuConverter : ValueConverter<ProductSku, string>
|
||||
{
|
||||
public SkuConverter()
|
||||
: base(x => x.ToString(), x => new ProductSku(x))
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user