Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

What is wrong with putting Using Blocks in Repository

By: a guest on Feb 27th, 2012  |  syntax: None  |  size: 0.55 KB  |  views: 18  |  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. public IList<something> GetSomething()
  2. {
  3.    using (DB db=new DB())
  4.  
  5.    { ...GetListofSomethingElse(id)
  6.  
  7.    }
  8. }
  9.  
  10. public IList<somethingelse> GetListofSomethingElse(int id)
  11. {
  12.     using (DB db=new DB())
  13.    {
  14.      ... return IList
  15.  
  16.    }
  17. }
  18.        
  19. using( ISession s = theSessionFactory.OpenSession() )
  20. {
  21.     ICustomerRepository cr = RepositoryFactory.GetCustomerRepository(s);
  22.  
  23.     Customer c1 = cr.GetCustomer(1);
  24.     Customer c2 = cr.GetCustomer(2);
  25.  
  26.     // do some other stuff
  27.     s.StartTransaction();
  28.  
  29.     cr.Save (c1);
  30.     cr.Save (c2);
  31.  
  32.     s.Commit();
  33.  
  34. }
clone this paste RAW Paste Data