Come implementare la relazione M-N per riflettere correttamente il dominio

0

Se ho tre entità come questa:

  1. workinggroup
  2. workingtime
  3. Maiusc

Il WorkingGroup ha uno o più tempi di lavoro

public class WorkingGroup
    {
        public WorkingGroup()
        {
            IsActive = true;
            IsDefault = false;
            WorkingTimes = new List<WorkingTime>();
        }
        private ICollection<WorkingTime> _workingTimes;

        public int Id { get; set; }
        public string Name { get; set; }
        public short NumberOfSuccessions { get; set; }
        public short WeekStart { get; set; }
        public bool IsActive { get; set; }
        public bool IsDefault { get; set; }
        public short NumberOfWeekends { get; set; }
        public virtual ICollection<WorkingTime> WorkingTimes { get => _workingTimes; set => _workingTimes = value; }
    }
public class WorkingTime
    {
        public WorkingTime()
        {
            WorkingTimeActivations = new List<WorkingTimeActivation>();
        }
        private ICollection<WorkingTimeActivation> _workingTimeActivations;
        public int Id { get; set; }
        public string Name { get; set; }
        public short NumberOfHours { get; set; }
        public short NumberOfShortDays { get; set; }
        public int WorkingGroupId { get; set; }
        public WorkingGroup WorkingGroup { get; set; }
        public ICollection<WorkingTimeActivation> WorkingTimeActivations { get => _workingTimeActivations; set => _workingTimeActivations = value; }
    }
public class Shift
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int ShiftType { get; set; }
        public DateTime ShiftStart { get; set; }
        public DateTime ShiftEnd { get; set; }
        public DateTime DayStart { get; set; }
        public DateTime DayEnd { get; set; }
        public TimeSpan GracePeriodStart { get; set; }
        public TimeSpan GracePeriodEnd { get; set; }
    }

Ora sono un po 'confuso su come implementare la relazione tra WorkingTime & Shift Sembra la relazione M-N . WorkingTime per WorkingGroup (A) ha 2 record (8 ore estive, 6 ore invernali)

Ora Se l'utente seleziona WorkingGroup (A) per creare un shift per esso: Dovrebbe creare uno spostamento per workingTime(Summer) ad esempio da 08:00 to 16:00 , e un altro per workingTime(Winter) ad esempio da 08:00 to 14:00

What's the aggregate root in this case? and How to implement this relationship to reflect it correctly in DB?

    
posta Anyname Donotcare 21.04.2018 - 22:58
fonte

0 risposte