访问包装对象
我正在将 ORM 实体包装到业务对象中。
public class ProjectMember
{
private readonly TfProjectMembersEntity _projectMembersEntity;
public ProjectMember(TfProjectMembersEntity projectMembersEntity)
{
_projectMembersEntity = projectMembersEntity;
}
#region Props
public string Email
{
get { return _projectMembersEntity.Email; }
set { _projectMembersEntity.Email = value; }
}
public DateTime Created
{
get { return _projectMembersEntity.Created; }
set { _projectMembersEntity.Created = value; }
}
}
该业务对象由存储库返回。出路并不复杂。问题是当将包装对象传递到存储库以进行保存操作时如何访问包装实体。
获取包裹对象的巧妙方法是什么?
I'm wrapping my ORM entities into bussines objects.
public class ProjectMember
{
private readonly TfProjectMembersEntity _projectMembersEntity;
public ProjectMember(TfProjectMembersEntity projectMembersEntity)
{
_projectMembersEntity = projectMembersEntity;
}
#region Props
public string Email
{
get { return _projectMembersEntity.Email; }
set { _projectMembersEntity.Email = value; }
}
public DateTime Created
{
get { return _projectMembersEntity.Created; }
set { _projectMembersEntity.Created = value; }
}
}
This bussines objects are returned by the repository. The way out isn't complicated. The problem is how to access the wrapped entity when a wrapped object is passed to a repository for a save operation.
What would be a neat way, to get the wrapped object ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需添加一个方法或属性?
您可以像这样创建一个接口:
现在您可以让您的 BO 实现该接口。您甚至可以创建一个实现该接口的基类,并从该基类派生您的 BO。
编辑:
将 DTO 更改为实体以符合您的代码。
Simply add a method or property?
You could create an Interface like so:
Now you could make your BOs implement that interface. You could even create a base class implementing that interface and derive your BOs from that base class.
EDIT:
Changed DTO to Entity to conform with your code.