G
Guest
Hello,
I have a class that inherits from the CollectionBase class that contains
records from a table in database that has a compound key.
Items Table
Company_ID [PK, int]
Item_ID [PK, int]
Description [varchar(50)]
Does anyone have any suggestions on how to implement a property, similar to
Item(index as Integer), that accepts the compound keys?
Desired Property
Item(company_id As Integer, item_id as Integer) As CompanyItem
Currently if the table has only a primary key, I create a hashtable to store
the primary key and the index of the object.
Private m_htKeys As Hashtable
Default Public Property Item(ByVal key As String) As CompanyItem
Get
Return list.Item(m_htKeys.Item(key))
End Get
Set(ByVal Value As CompanyItem)
list.Item(m_htKeys.Item(key)) = Value
End Set
End Property
I have tried storing the compound keys as a String Array in the hashtable,
however when I try to find that String Arrary again it just returns the first
object.
Is there a better way of going about this? Am I crazy?
Justin
I have a class that inherits from the CollectionBase class that contains
records from a table in database that has a compound key.
Items Table
Company_ID [PK, int]
Item_ID [PK, int]
Description [varchar(50)]
Does anyone have any suggestions on how to implement a property, similar to
Item(index as Integer), that accepts the compound keys?
Desired Property
Item(company_id As Integer, item_id as Integer) As CompanyItem
Currently if the table has only a primary key, I create a hashtable to store
the primary key and the index of the object.
Private m_htKeys As Hashtable
Default Public Property Item(ByVal key As String) As CompanyItem
Get
Return list.Item(m_htKeys.Item(key))
End Get
Set(ByVal Value As CompanyItem)
list.Item(m_htKeys.Item(key)) = Value
End Set
End Property
I have tried storing the compound keys as a String Array in the hashtable,
however when I try to find that String Arrary again it just returns the first
object.
Is there a better way of going about this? Am I crazy?
Justin