Is it correct to use Specification Pattern with Navigation Properties ?
I have the follow context:
When I add a student, I need to validate the addresses.
Student class:
public class Student {
public string Name { get; set; }
public DateTime Birth { get; set; }
//...
public virtual ICollection<StudentAddress> StudentAdresses { get; set; }
}
StudentAddress class:
public class StudentAdress{
public int Id { get; set;}
public string Street { get; set; }
//...
}
On my student service (DDD):
Service:
public void AddStudent(Student student)
{
// code
var studentValidation = new StudentValidation().Validate(student); // Student Validation has a set of specifications that will populate a validation result object and that I'll retrieve it by Domain Controller Notification (MVC)
// code
}
PS: Student Validation has a set of specifications that will populate a validation result object and that I'll retrieve it by Domain Controller Notification (MVC)
Back to the question...
Where may I put my Student Addresses class specifications ?
I thought of the possibility of putting them inside StudentValidation class and there use the Navigation property to be able to validate each address. I do not know if that is correct. It would be a type of transversal validation.