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;
}
精彩评论