public IList <T> GetAll() { using (var db = new TestverktygContext()) { return(db.Set <T>().ToList()); } }
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); } } }
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); } } }