Link to home
Start Free TrialLog in
Avatar of JRockFL
JRockFLFlag for United States of America

asked on

Winforms - Caching Data

I have a winforms application and would like to cache the look up tables when the application loads.
I would like to have a collection of table names and then when the application loads, iterate through the collection
and then cache each table.

Any suggestions to get me started?
Avatar of Kumaraswamy R
Kumaraswamy R
Flag of India image

Subscribe
You can declare some DataTable objects at the module level. In the form load of the main form, load these tables. Then you can use these tables across the whole application. Any variable/function in module has an application level scope.
Avatar of JRockFL

ASKER

CodeCruiser,

Thank you for your reply. I actual use entities objects for data and another class that inherits from collectionbase class.

Public Class StatesCollection
   Inherits CollectionBase
End Class


Without making this a shared class, what do you suggestion for caching?
I wanted to have a table that just stored the table name, then I could iterate through all of the tables.


Public Class TableCache

End Class

Public TableCacheCollection
   Inherits CollectionBase
End Class

For each tc As TableCache in TableCacheColletion
'cache the some objects
'what do you suggest?
Next
I am not sure why you want to store the table names in the collection and have the caching enabled by this. You need to store the table contents somewhere as well. If you dont know the table names and how do you use them in code?
Avatar of JRockFL

ASKER

I wanted to store the names of the tables that I want to cache.
So I would have table in Sql Server called TableCache.
In this table, I would then list all of the names of the tables that I would want to cache.
For example, States.

Then When the application loaded, I could query the tablecache table and determine all of the tables that would be cached.

Does that make sense?
Yes. But that is not much complicated is it? Do you need to code for writing to and reading from this table?
Avatar of JRockFL

ASKER

Ok let's not worry about that then.
What do you recommend for caching objects like this then?


Public Class StatesCollection
   Inherits CollectionBase
End Class

I would use variables in a module to store these objects.
Avatar of JRockFL

ASKER

Ok, can you provide me a quick code sample?
I'm not familiar with a module
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial