public ActionResult Index(ProductSearchCriteria criteria) { var sqlQuery = new SqlSearchProductQuery(criteria); var watch = System.Diagnostics.Stopwatch.StartNew(); var result = sqlQuery.Execute(); watch.Stop(); var sqlElapsedMs = watch.ElapsedMilliseconds; var redisQuery = new SearchProductQuery(criteria); watch = System.Diagnostics.Stopwatch.StartNew(); result = redisQuery.Execute(); watch.Stop(); var redisElapsedMs = watch.ElapsedMilliseconds; var viewModel = new SearchResultViewModel <ProductModel>(); viewModel.Data = result; viewModel.SqlQueryTime = sqlElapsedMs; viewModel.RedisQueryTime = redisElapsedMs; ViewBag.Heading = "Compare View"; return(View(viewModel)); }
public ActionResult Search(ProductSearchCriteria criteria) { var watch = System.Diagnostics.Stopwatch.StartNew(); var query = new SearchProductQuery(criteria); var result = query.Execute(); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; var viewModel = new SearchResultViewModel <ProductModel>(); viewModel.Data = result; viewModel.QueryTime = elapsedMs; return(PartialView("~/Views/Products/_Search.cshtml", viewModel)); }
public ActionResult Index(ProductSearchCriteria criteria) { var watch = System.Diagnostics.Stopwatch.StartNew(); var query = new SearchProductQuery(criteria); var result = query.Execute(); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; var viewModel = new SearchResultViewModel <ProductModel>(); viewModel.Data = result; viewModel.QueryTime = elapsedMs; ViewBag.Heading = "Query with Redis and Elastic Search"; ViewBag.IsSql = false; return(View(viewModel)); }