示例#1
0
 public IList <T> GetAll()
 {
     using (var db = new TestverktygContext())
     {
         return(db.Set <T>().ToList());
     }
 }
示例#2
0
 public bool Delete(T data)
 {
     using (var db = new TestverktygContext())
     {
         try
         {
             db.Set <T>().Attach(data);
             db.Set <T>().Remove(data);
             db.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             Debug.WriteLine(e.Message);
             return(false);
         }
     }
 }
示例#3
0
 public T Get(int id)
 {
     using (var db = new TestverktygContext())
     {
         try
         {
             return(db.Set <T>().Find(id));
         }
         catch (Exception e)
         {
             Debug.WriteLine(e.Message);
             return(null);
         }
     }
 }