using Furion.DatabaseAccessor;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace YBEE.EQM.Core;
///
/// 监测年级
///
[Comment("监测年级")]
public class ExamGrade : DEntityBase, IEntityTypeBuilder
{
///
/// 监测计划ID
///
[Comment("监测计划ID")]
[Required]
public int ExamPlanId { get; set; }
///
/// 年级ID
///
[Comment("年级ID")]
[Required]
public short GradeId { get; set; }
///
/// 年份(级)
///
[Comment("年份(级)")]
[Required]
public short GradeBeginYear { get; set; }
///
/// 年份(届)
///
[Comment("年份(届)")]
[Required]
public short GradeEndYear { get; set; }
///
/// 学段
///
[Comment("学段")]
[Required, Column(TypeName = "smallint")]
public EducationStage EducationStage { get; set; }
///
/// 学制
///
[Comment("学制")]
[Required]
public short EducationYears { get; set; }
///
/// 是否需要自编监测号
///
[Comment("是否需要自编监测号")]
[Required]
public bool IsRequiredSelfExamNumber { get; set; } = false;
///
/// 自编监测号长度
///
[Comment("自编监测号长度")]
[Required]
public short SelfExamNumberLength { get; set; } = 0;
///
/// 是否需要抽样监测
///
[Comment("是否需要抽样监测")]
[Required]
public bool IsRequiredSample { get; set; } = true;
///
/// 总分分数段类型
///
[Comment("总分分数段类型")]
public ExamScoreRangeType ExamScoreRangeType { get; set; } = ExamScoreRangeType.NONE;
///
/// 备注
///
[Comment("备注")]
[StringLength(200)]
public string Remark { get; set; } = "";
///
/// 一对一引用(年级)
///
public virtual Grade Grade { get; set; }
///
/// 一对一引用(监测计划)
///
public virtual ExamPlan ExamPlan { get; set; }
///
/// 一对多引用(监测科目)
///
public ICollection ExamCourses { get; } = new List();
public void Configure(EntityTypeBuilder entityBuilder, DbContext dbContext, Type dbContextLocator)
{
entityBuilder.HasIndex(x => new { x.ExamPlanId, x.GradeId }).IsUnique().HasDatabaseName("idx_exam_grade_exam_plan_id_grade_id");
}
}