Advertisement
Guest User

Untitled

a guest
May 29th, 2016
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. namespace LibDataAccess {
  2. using System;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. using Microsoft.Data.Entity;
  6. using Models;
  7. using Microsoft.Data.Entity.Metadata;
  8.  
  9. public class MyDBContext : DbContext {
  10. public MyDBContext Save<T>(T entity) where T : class {
  11. this.Add<T>(entity: entity);
  12. try {
  13. this.SaveChanges();
  14. } catch (Exception ex) {
  15. throw;
  16. }
  17. return this;
  18. }
  19.  
  20. public MyDBContext Save(object entity) {
  21. this.Add(entity: entity);
  22. try {
  23. this.SaveChanges();
  24. } catch (Exception ex) {
  25. throw;
  26. }
  27. return this;
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement