Exemple #1
0
 //Get All
 public virtual IEnumerable <T> GetAll()
 {
     using (var myContext = new KoontabiDBEntities())
     {
         var objectContext = ((IObjectContextAdapter)myContext).ObjectContext;
         return(objectContext.CreateObjectSet <T>().ToList());
     }
 }
Exemple #2
0
 //Delete
 public void Delete(T t)
 {
     using (var myContext = new KoontabiDBEntities())
     {
         var objectContext = ((IObjectContextAdapter)myContext).ObjectContext;
         objectContext.DeleteObject(t);
     }
 }
Exemple #3
0
 //Read
 public virtual T Find(Expression <Func <T, bool> > specification)
 {
     using (var myContext = new KoontabiDBEntities())
     {
         var objectContext = ((IObjectContextAdapter)myContext).ObjectContext;
         return(objectContext.CreateObjectSet <T>().FirstOrDefault(specification));
     }
 }
Exemple #4
0
 //Create
 public virtual void Add(T t)
 {
     using (var myContext = new KoontabiDBEntities())
     {
         myContext.Entry(t).State = System.Data.Entity.EntityState.Added;
         myContext.SaveChanges();
     }
 }
Exemple #5
0
 //Update
 public virtual void Update(T t)
 {
     using (var myContext = new KoontabiDBEntities())
     {
         myContext.Entry(t).State = System.Data.Entity.EntityState.Unchanged;
         myContext.Entry(t).State = System.Data.Entity.EntityState.Modified;
         myContext.SaveChanges();
     }
 }