Skip to content

Instantly share code, notes, and snippets.

@mikecole
Created March 7, 2014 15: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 mikecole/9413854 to your computer and use it in GitHub Desktop.
Save mikecole/9413854 to your computer and use it in GitHub Desktop.
Automapper Multiple Sources
public ActionResult Index(int accountId)
{
var account = _accountContext.Accounts.SingleOrDefault(acct => acct.ID == accountId);
var history = _financialContext.AccountHistory.Where(acct => acct.ID == accountId);
var paymentInfo = _paymentProcessor.GetPaymentProfile(accountId);
var sources = new Tuple<Account, IEnumerable<Transaction>, PaymentProfile>(account, history, paymentInfo);
var model = Mapper.Map<AccountSummaryViewModel>(sources);
return View(model);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment