Skip to content

Instantly share code, notes, and snippets.

@danielplawgo
Created June 14, 2018 09:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielplawgo/f14942396e704203f68165de1e17e381 to your computer and use it in GitHub Desktop.
Save danielplawgo/f14942396e704203f68165de1e17e381 to your computer and use it in GitHub Desktop.
MiniProfiler
@MiniProfiler.RenderIncludes()
public virtual ActionResult Index2()
{
using (MiniProfiler.Current.Step("Index2 action"))
{
IEnumerable<UserViewModel> viewModels;
var models = db.Users.ToList();
using (MiniProfiler.Current.Step("Mapping with automapper"))
{
viewModels = Mapper.Map<List<UserViewModel>>(models);
}
return View(viewModels);
}
}
public virtual ActionResult Index3()
{
using (MiniProfiler.Current.Step("Index3 action"))
{
IEnumerable<UserViewModel> viewModels;
var models = db.Users.ToList();
using (MiniProfiler.Current.Step("Mapping without automapper"))
{
viewModels = models.Select(u => new UserViewModel()
{
Id = u.Id,
Email = u.Email,
FirstName = u.FirstName,
LastName = u.LastName,
CreateInvoice = u.CreateInvoice,
UserName = u.UserName,
Nip = u.Nip
}).ToList();
}
return View(Views.Index2, viewModels);
}
}
<add name="MiniProfiler" path="mini-profiler-resources/*" verb="*" type="System.Web.Routing.UrlRoutingModule" resourceType="Unspecified" preCondition="integratedMode" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment