need help with generics - multi key lookup
-
Hi All, This is my first post and hope i am placing it in the right forums - I have the following class Class User Dim UserID as integer Dim IsActive as boolean Dim Username as string End Class i need to perform lookups on UserID or IsActive Get user with ID = X (returns one object) Get all active Users (returns multiple objects - possibly a list) Get all inactive users (returns multiple objcets - possibly a list) for quicker retrieval using userid, i intend to use the generics dictionary dim Users as Dictionary (Of integer, User) are there any generics implementations which allow me to use quickly retrieve all active users or inactive users as well? Just wanted to check with you experts before embarking on my own. :) Thanks in advance Kalyan
-
Hi All, This is my first post and hope i am placing it in the right forums - I have the following class Class User Dim UserID as integer Dim IsActive as boolean Dim Username as string End Class i need to perform lookups on UserID or IsActive Get user with ID = X (returns one object) Get all active Users (returns multiple objects - possibly a list) Get all inactive users (returns multiple objcets - possibly a list) for quicker retrieval using userid, i intend to use the generics dictionary dim Users as Dictionary (Of integer, User) are there any generics implementations which allow me to use quickly retrieve all active users or inactive users as well? Just wanted to check with you experts before embarking on my own. :) Thanks in advance Kalyan
you could: - just use a dictionary (key=UserId) and test IsActive as appropriate; - keep one dictionary (key=UserId), and two lists (one with active, one with inactive users); - keep two dictionaries, one with active and one with inactive users; - use a DataTable; - use lambda expressions. IMO the best choice depends a bit on the circumstances where you need it. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
-
you could: - just use a dictionary (key=UserId) and test IsActive as appropriate; - keep one dictionary (key=UserId), and two lists (one with active, one with inactive users); - keep two dictionaries, one with active and one with inactive users; - use a DataTable; - use lambda expressions. IMO the best choice depends a bit on the circumstances where you need it. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.
Hi Luc, Thanks for a quick reply. I looked at generics and was hoping there may be a complex alternative which i might find interesting :omg: i have opted for the following to keep it simple 1 dictionary for quick retrieval by userid 2 lists for containing active and inactive users. i wonder how this will scale for larger number of users! Thanks to you i learnt about lambda expressions today. :thumbsup: Go you still prefer datatables for these kind of operations when dealing with disconnected data? Cheers Kalyan
-
Hi Luc, Thanks for a quick reply. I looked at generics and was hoping there may be a complex alternative which i might find interesting :omg: i have opted for the following to keep it simple 1 dictionary for quick retrieval by userid 2 lists for containing active and inactive users. i wonder how this will scale for larger number of users! Thanks to you i learnt about lambda expressions today. :thumbsup: Go you still prefer datatables for these kind of operations when dealing with disconnected data? Cheers Kalyan
you're welcome. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that.
All Toronto weekends should be extremely wet until we get it automated in regular forums, not just QA.