mirror of
https://github.com/farcasclaudiu/PracticeCalendar.git
synced 2026-06-28 17:01:13 +03:00
play with storing valueobjects
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using PracticeCalendar.Domain.Entities;
|
||||
using PracticeCalendar.Domain.Entities.PracticeEvent;
|
||||
|
||||
namespace PracticeCalendar.Infrastructure.Persistence.Configuration
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using PracticeCalendar.Domain.Entities;
|
||||
using PracticeCalendar.Domain.Entities.PracticeEvent;
|
||||
|
||||
namespace PracticeCalendar.Infrastructure.Persistence.Configuration
|
||||
{
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using PracticeCalendar.Domain.Entities.Product;
|
||||
using PracticeCalendar.Domain.ValueObjects;
|
||||
|
||||
namespace PracticeCalendar.Infrastructure.Persistence.Configuration
|
||||
{
|
||||
public class ProductConfiguration : IEntityTypeConfiguration<Product>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Product> builder)
|
||||
{
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.Category)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
builder.OwnsOne(product => product.UnitPrice, price =>
|
||||
{
|
||||
price.Property(p => p.Currency)
|
||||
.HasColumnName(nameof(Price.Currency))
|
||||
.HasMaxLength(5)
|
||||
.IsRequired();
|
||||
price.Property(p => p.Value)
|
||||
.HasColumnName(nameof(Price.Value))
|
||||
.IsRequired();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user