开发者

How to create Local Data Caching in c# WinApps?

开发者 https://www.devze.com 2022-12-30 07:34 出处:网络
Anyone can give me an example on how to create local data c开发者_运维百科aching? Like for example I query 10 millions records from my DB and I want to store it in my local so that I would not encount

Anyone can give me an example on how to create local data c开发者_运维百科aching? Like for example I query 10 millions records from my DB and I want to store it in my local so that I would not encounter performance problem next time when I want to reload the data. Thank you so much.


You can use a static List<T> where T is your entity..


Since you only want a cache during the lifetime of the application, you can use a DataSet for this purpose (assuming you have enough memory). Just read one into the DataSet and from then on only ever read from it:

DataSet myData = null;

public DataSet GetMyData()
{
   if (myData == null)
   {
      myData = GetDataFromDatabase();
   }
   return myData;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消