I have a class Lawsuitthat has a list Employer. There is a requirement that one of the employers on the list must be appointed as the main employer. I thought of two ways to enforce this business rule.
Solution 1
This is my current implementation, I have it MainEmployer, and I keep the same object in this property and in the list Employers:
public class Lawsuit()
{
public int Id { get; set; }
public virtual Employer MainEmployer { get; set; }
public virtual ICollection<Employer> Employers { get; set; }
}
Decision 2
I could also create an intermediate class EmployerLawsuitwith a bool property called Main:
public class LawsuitEmployer()
{
public int Id { get; set; }
public bool Main { get; set; }
public virtual Employer Employer { get; set; }
public virtual Lawsuit Lawsuit { get; set; }
}
public class Lawsuit()
{
public int Id { get; set; }
public virtual ICollection<EmployerLawsuit> Employers { get; set; }
}
Which of these two approaches is better to consider the performance of the resulting database (I use the Entity Framework) and the principles of SOLID? Or is there a better way to model these objects?