我使用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',這是不允許的。有人能讓我挺直嗎?
正是我失蹤的!乾杯。 – Simon 2008-10-11 16:45:34