using FileService.Domain.Entities; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Metadata.Builders; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace FileService.Infrastructure.Configs { public class UploadFileConfig : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { builder.ToTable("upload_files"); builder.Property(x => x.FileName) .HasConversion( a => a.Value, b => new Domain.ValueObjects.FileName(b) ); builder.Property(x => x.ContentType) .HasConversion( a => a.Value, b => new Domain.ValueObjects.ContentType(b) ); builder.ComplexProperty(x => x.CheckSum, c => { c.Property(p => p.Value) .HasColumnName("checksum_value"); c.Property(p => p.Algorithm) .HasColumnName("checksum_algorithm"); }); builder.ComplexProperty(x => x.StorageLocation, c => { c.Property(p => p.StorageProvider) .HasColumnName("storage_provider"); c.Property(p => p.ObjectKey) .HasColumnName("storage_key"); c.Property(p => p.Region) .HasColumnName("storage_region"); c.Property(p => p.Bucket) .HasColumnName("storage_bucket"); }); } } }