public static void Delete <T>(object id) where T : class
 {
     using (var context = new BasicWebContext())
     {
         var record = context.Set <T>().Find(id);
         context.Set <T>().Remove(record);
         context.SaveChanges();
     }
 }
 public static void DeleteAll <T>(System.Linq.Expressions.Expression <Func <T, bool> > selector) where T : class
 {
     using (var context = new BasicWebContext())
     {
         var records = context.Set <T>().Where(selector);
         foreach (var record in records)
         {
             context.Set <T>().Remove(record);
         }
         context.SaveChanges();
     }
 }
 public static List <T> Query <T>(System.Linq.Expressions.Expression <Func <T, bool> > condition) where T : class
 {
     using (var context = new BasicWebContext())
     {
         return(context.Set <T>().Where(condition).ToList());
     }
 }
 public static List <T> GetAll <T>() where T : class
 {
     using (var context = new BasicWebContext())
     {
         return(context.Set <T>().AsNoTracking().ToList());
     }
 }
 public static T Get <T>(object id) where T : class
 {
     using (var context = new BasicWebContext())
     {
         return(context.Set <T>().Find(id));
     }
 }
 public static void New <T>(T record) where T : class
 {
     using (var context = new BasicWebContext())
     {
         context.Set <T>().Add(record);
         context.SaveChanges();
     }
 }
 public static void Update <T>(object id, Action <T> action) where T : class
 {
     using (var context = new BasicWebContext())
     {
         var record = context.Set <T>().Find(id);
         action(record);
         context.SaveChanges();
     }
 }
 public static void NewAll <T>(IEnumerable <T> records) where T : class
 {
     using (var context = new BasicWebContext())
     {
         foreach (var record in records)
         {
             context.Set <T>().Add(record);
         }
         context.SaveChanges();
     }
 }