Hello Everyone!
I've this scenario (Pretty Common!):
Customer Object Root Object
Invoice Object Root Object
The doubt that I have its related with the Invoice Having a (HAS A) Customer Object, how can I implement the aggregation??
Should I use a Customer Root Object inside the Invoice Object and Load it, Save It, Etc in the Invoice DATAPORTAL Methods? Or should I interact with the database directly ???
What do you guys recommend??
Something like this:
Private Overloads Sub DataPortal_Fetch(ByVal criteria As Criteria)
Using cn As New SqlConnection(Database.RedStarDBConnection)
cn.Open()
Using cm As SqlCommand = cn.CreateCommand
cm.CommandType = CommandType.StoredProcedure
cm.CommandText = "sp_SelectInvoice"
cm.Parameters.AddWithValue("@InvoiceID", criteria.Id)
Using dr As New SafeDataReader(cm.ExecuteReader)
dr.Read()
With dr
mInvoiceID = .GetInt32("InvoiceID")
mCustomerID = .GetInt32("CustomerID")
xCustomer = Customer.GetCustomer(mCustomerID)
‘Load Customer Information
With xCustomer
mCustomerID = .CustomerID
mFullName = .FullName
mFullAddress = .FullAddress
mHomePhone = .HomePhone
mWorkPhone = .WorkPhone
mCellPhone = .CellPhone
End With
‘load Invoice Information
mInvoiceDate = .GetSmartDate("InvoiceDate", mInvoiceDate.EmptyIsMin)
...more code …
THANKS in ADVANCE!
Copyright (c) Marimer LLC