Created
June 15, 2010 06:57
-
-
Save schotime/438783 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Take this | |
public ActionResult Logins() | |
{ | |
var mapped = _repository | |
.Query(new GetLoginHistoryAndUser()) | |
.AutoMap<LoginHistory, LoginHistoryDisplay>() | |
.ToList(); | |
return View(new LoginHistoryViewModel { LoginHistory = mapped }); | |
} | |
//with this | |
public static IEnumerable<Y> AutoMap<T, Y>(this IEnumerable<T> list) | |
{ | |
return list.Select(x => Mapper.Map<T, Y>(x)); | |
} | |
//Why can't i write this (omitting the first type in the AutoMap method) | |
public ActionResult Logins() | |
{ | |
var mapped = _repository | |
.Query(new GetLoginHistoryAndUser()) | |
.AutoMap<LoginHistoryDisplay>() | |
.ToList(); | |
return View(new LoginHistoryViewModel { LoginHistory = mapped }); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment