Guest User

Untitled

a guest
May 2nd, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment