Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void Main()
- {
- const string CleanBuffersSqlQuery = "CHECKPOINT; DBCC DROPCLEANBUFFERS;";
- const int NumberOfIterations = 10;
- Stopwatch stopwatch = new Stopwatch();
- for (int i = 0; i < NumberOfIterations; i++)
- {
- using (var context = new AdsEntities())
- {
- context.Database.SqlQuery<string>(CleanBuffersSqlQuery);
- stopwatch.Start();
- var ads =
- context.Ads.ToList()
- .Where(a => a.AdStatus.Status == "Published")
- .Select(a => new { a.Title, a.Category, a.Town, a.Date })
- .ToList()
- .OrderBy(a => a.Date);
- stopwatch.Stop();
- Console.WriteLine("Iteration {0}: {1}", i + 1, stopwatch.Elapsed);
- }
- stopwatch.Reset();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement