Files
IM_NEW/FileService.Infrastructure/Configs/UploadFileConfig.cs
T

65 lines
2.1 KiB
C#

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<UploadFile>
{
public void Configure(EntityTypeBuilder<UploadFile> builder)
{
builder.ToTable("upload_files");
builder.Property(x => x.FileName)
.HasMaxLength(255)
.HasConversion(
a => a.Value,
b => new Domain.ValueObjects.FileName(b)
);
builder.Property(x => x.ContentType)
.HasMaxLength(255)
.HasConversion(
a => a.Value,
b => new Domain.ValueObjects.ContentType(b)
);
builder.ComplexProperty(x => x.CheckSum, c =>
{
c.Property(p => p.Value)
.HasMaxLength(128)
.HasColumnName("checksum_value");
c.Property(p => p.Algorithm)
.HasMaxLength(16)
.HasColumnName("checksum_algorithm");
});
builder.HasIndex(x => x.SourceTaskId).IsUnique();
builder.Property(x => x.ChatType).HasMaxLength(16);
builder.ComplexProperty(x => x.StorageLocation, c =>
{
c.Property(p => p.StorageProvider)
.HasMaxLength(64)
.HasColumnName("storage_provider");
c.Property(p => p.ObjectKey)
.HasMaxLength(1024)
.HasColumnName("storage_key");
c.Property(p => p.Region)
.HasMaxLength(128)
.HasColumnName("storage_region");
c.Property(p => p.Bucket)
.HasMaxLength(255)
.HasColumnName("storage_bucket");
});
}
}
}