LINQの結果をCache オブジェクトに保存します。Queryからキーを自動的に生成しているため、簡単に使うことができます。詳しくは下記のサイトをご覧ください。

Caching the results of LINQ queries
http://petemontgomery.wordpress.com/2008/08/07/caching-the-results-of-linq-queries/

1.MSDNに記載されている ExpressionVisitor クラスをプロジェクトに追加します。

ExpressionVisitor
http://msdn.microsoft.com/en-us/library/bb882521.aspx

2.Caching the results of LINQ queries の Source code にある QueryResultCache クラス, Evaluator クラスをプロジェクトに追加します。

3.あとは通常のFromCacheメゾット を呼び出すだけで使用できます。

using (DataClassesDataContext db = new DataClassesDataContext())
{
	var people = from p in db.Person
		where p.IsReal == true
		select p;

		var result = people.FromCache().ToList();
}

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading