using APT.BaseData.Domain.Entities;
using APT.Infrastructure.EF.Map;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace APT.BaseData.Data.Mapping
{
	public class PFColumnMap : APTEntityBaseMap<T_PF_COLUMN>
    {
		public override void Configure(EntityTypeBuilder<T_PF_COLUMN> builder)
		{
			base.Configure(builder);

			// Properties
			builder.Property(t => t.TABLE_NAME)
				.HasMaxLength(50);

			builder.Property(t => t.FIELD_NAME)
			   .HasMaxLength(100);

			builder.Property(t => t.LABEL)
			  .HasMaxLength(64);
			builder.Property(t => t.ENUM)
		   .HasMaxLength(64);

			builder.Property(t => t.VALIDATA_TYPE)
		   .HasMaxLength(5);

			builder.Property(t => t.FORMAT)
			.HasMaxLength(600);
			//builder.Property(t => t.Mapping_Table).HasMaxLength(100);
			builder.Property(t => t.MERGE_CELLS).HasMaxLength(600);

			//builder.Ignore(t => t.CREATER_ID);

			//builder.HasOptional(t => t.Nav_Creater).WithMany().HasForeignKey(t => t.CREATER_ID);

			builder.Property(t => t.SHOW_FORM_CODE).HasMaxLength(60);
			builder.Property(t => t.SHOW_ID_FIELD).HasMaxLength(500);

			builder.Property(t => t.CUSTOM_PARAMS).HasMaxLength(600);

			builder.Property(t => t.INPUT_DATA_API)
		   .HasMaxLength(64);
			builder.Property(t => t.INPUT_SORT_FIELD)
			.HasMaxLength(100);
			builder.Property(t => t.INPUT_SORT_ORDER)
			.HasMaxLength(50);

			builder.Property(t => t.INPUT_ID_FIELD)
	  .HasMaxLength(50);
			builder.Property(t => t.INPUT_FILTER_FIELD)
		  .HasMaxLength(100);
			builder.Property(t => t.INPUT_SHOW_FIELD)
		  .HasMaxLength(100);
			builder.Property(t => t.INPUT_LABEL_FIELD)
				 .HasMaxLength(100);
			builder.Property(t => t.INPUT_SAVE_FIELD)
				 .HasMaxLength(600);
			builder.Property(t => t.INPUT_NAV_FIELD)
					 .HasMaxLength(600);


			builder.HasOne(t => t.Nav_PageTablePanel).WithMany().HasForeignKey(t => t.PAGE_TABLE_PANEL_ID).OnDelete(DeleteBehavior.Restrict);
		} 
    }
}
