VB
An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,737 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hallo,
I have a class with Customer and orders and how do i place a dummy order when i initialize customer so that the customer already has 1 order?
Public Class Customer
Public Sub New()
ordersValue = New Orders()
End Sub
Private WithEvents ordersValue As Orders
Public Property Orders() As Orders
Get
Return ordersValue
End Get
Set(ByVal value As Orders)
ordersValue = value
End Set
End Property
End Class
Public Class Order
Public Sub New()
End Sub
Private orderIDValue As String
Public ReadOnly Property OrderID() As String
Get
Return orderIDValue
End Get
End Property
End class
Thanks
Hello @Hobbyist_programmer
See if this is helpful, there are some additional properties that may or may not be in your classes. Note Customeridentifier and OrderId would both be -1 until the primary key is returned from inserting a customer, same with order. If this was Entity Framework both keys would be handled by entity framework 6 or entity framework core.
Public Class Customer
Public Property Id() As Integer
Public Sub New()
Orders = New List(Of Orders)
Orders.Add(New Orders() With {
.OrderId = -1,
.CustomerIdentifier = -1,
.OrderDate = Now})
End Sub
Public Property CompanyName() As String
Public Property ContactId() As Integer
Public Property CountryIdentifier() As Integer
Public Property Orders() As List(Of Orders)
End Class
Public Class Orders
Public Property OrderId() As Integer
Public Property OrderDate() As Date
Public Property CustomerIdentifier() As Integer
Public Property ShipAddress() As String
Public Property ShipCity() As String
Public Property ShipPostalCode() As String
Public Property ShipCountryIdentifier() As Integer
End Class
Public Class Country
Public Property CountryIdentifier() As Integer
Public Property Name() As String
End Class
Thanks Karen it helped.