假设我有一个如下所示的数据传输对象:
Public Class Person
Private _Name As String
Private _Age As Integer
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal value As String)
_Name = value
End Set
End Property
Public Property Age() As Integer
Get
Return _Age
End Get
Set(ByVal value As Integer)
_Age = value
End Set
End Property
结束类
这是下表的对象表示:
CREATE TABLE Person (PersonID int identity primary key, Name varchar(30), age int)
假设我想在数据库中创建一个订单表,如下所示:
CREATE TABLE Order (OrderID int identity primary key, PersonID FOREIGN KEY references Person(ID), OrderDate datetime)
我相信我可以简单地向数据传输对象添加另外两个实例变量和属性(假设每人总是最多一个订单)。这是可取的还是每个数据库表都应该有一个 DTO?