帮助在 asp.net 中定义域模型
我需要帮助模拟这个场景。
一个病人可以有很多医生,
一个医生可以有很多病人。
患者也是用户。 (MembershipUser)
医生也是用户。 (MembershipUser)
它们有很大不同,因为(例如)患者会进行多次体检,而医生则不会。
这应该是课程吗?将这样的类绑定到特定 MembershipUser 的标准方法是什么?
我很难理解这一点。
I need help modeling this scenario.
A Patient can have many medics
A Medic can have many patients.
A Patient is also a User. (MembershipUser)
A Medic is also a User. (MembershipUser)
They are quite different because (for example) a Patient will have many PhysicalExams whereas a Medic wouldn't.
Should this be classes? what is the standard approach of tying a class like this to a specific MembershipUser?
I have trouble understanding this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在域层使用类似的内容:
请注意,域代码不直接引用 ASP.NET 成员身份。您的基础结构可以负责将域 User 对象映射到 ASP.NET MembershipUser:
You can have something like this at the domain layer:
Note that domain code does not reference ASP.NET Membership directly. Your infrastructure can be responsible for mapping domain User object to ASP.NET MembershipUser:
根据您的解释,我只会有一个可能称为 User 的抽象基类,它定义患者和医生共享的重复属性和方法。
然后,我将在该基类中公开一个公共属性,即 MembershipUser 对象。
然后只需让 Patient 和 Medic 类继承 User 基类并实现各自独特的功能即可。
基本用户类还可以实现一个公共属性,该属性是 T 的列表,该列表具有将 T 限制为 User 对象的 where 子句,
如下所示:
From your explanation I would simply have a an abstract base class maybe called User which defines the duplicate properties and methods that both Patient and Medic share.
I would then have a public property exposed in that base class that is the MembershipUser object.
Then just make Patient and Medic classes inherit from the base User class and implement their respective unique functionality.
The base user class could also implement a public property that is a List of T that has a where clause that restricts T to User objects
Something like this: