code_junkie

When should I dispose of a data context

Nov 13th, 2011
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. private DataContext myDb;
  2. public static MyClass GetMyClassById(int id)
  3. {
  4. DataContext db = new DataContext();
  5. MyClass result = (from item in db.MyClasss
  6. where item.id == id
  7. select item).Single();
  8. result.myDb = db;
  9. return result;
  10. }
  11.  
  12. public void Save()
  13. {
  14. db.SubmitChanges();
  15. }
Add Comment
Please, Sign In to add comment