使用指定模式是否正确使用导航属性?带导航属性的指定模式
我有如下方面:
当我添加一个学生,我需要验证的地址。
学生类:
public class Student {
public string Name { get; set; }
public DateTime Birth { get; set; }
//...
public virtual ICollection<StudentAddress> StudentAdresses { get; set; }
}
StudentAddress类:
public class StudentAdress{
public int Id { get; set;}
public string Street { get; set; }
//...
}
在我的学生服务(DDD):
服务:
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:学生验证了一套规范,将填充验证结果对象,我会通过域控制器通知(MVC)
回到问题检索...
我可以在哪里放置我的学生地址班级规格?
我想到了将它们放入StudentValidation类中的可能性,并且使用Navigation属性可以验证每个地址。我不知道这是否正确。这将是一种横向验证。
为什么StudentAddress是一个实体?它应该是一个价值对象。 –
我认为我对这个问题的回答可能会指导你在正确的方向关于UI验证与域验证:http://stackoverflow.com/questions/28395176/should-i-abstract-the-validation-framework-from-domain-图层/ 28397201#28397201 – plalx
Constantin,StudentAddress是我DB上的表格。它具有身份,我认为价值对象是特定实体的一组属性。 –