我在 JCProperty 类中使用以下代码从 DAL 检索数据:
Dim x As JCProperty
x = JCPropertyDB.GetProperty(PropertyID)
If Not x Is Nothing Then
Me.PropertyID = x.PropertyID
Me.AddressLine1 = x.AddressLine1
Me.AddressLine2 = x.AddressLine2
Me.AddressLine3 = x.AddressLine3
Me.AddressCity = x.AddressCity
Me.AddressCounty = x.AddressCounty
Me.AddressPostcode = x.AddressPostcode
Me.TelNo = x.TelNo
Me.UpdatedOn = x.UpdatedOn
Me.CreatedOn = x.CreatedOn
Me.Description = x.Description
Me.GUID = x.GUID
End If
这工作正常,但需要 DAL 对象 (JCPropertyDB) 知道业务对象 (JCProperty),并且我有效地创建和填充相同的对象两次(一次在 DAL 中返回到 BL,然后再次在 BL 对象中填充本身)。
我在这里遗漏了一些东西,我知道一定有更好的方法!
实际上,我需要分配不允许的“Me = x”。有人可以让我直截了当吗?