Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.61 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to dispose objects correctly (ASP.NET MVC   Entity Framework)
  2. public ActionResult Detail(Guid id)
  3. {
  4.     Attachment attachment = null;
  5.     using (var attachmentRepository = IoC.Resolve<AttachmentRepository>())
  6.     {
  7.         attachment = attachmentRepository.SelectByKey(id);
  8.         return View("Detail", attachment);            
  9.     }          
  10. }
  11.        
  12. public ActionResult Detail(Guid id)
  13. {
  14.     Attachment attachment = null;
  15.     var attachmentRepository = IoC.Resolve<AttachmentRepository>();
  16.  
  17.     attachment = attachmentRepository.SelectByKey(id);
  18.     return View("Detail", attachment);                              
  19. }