Exemplo n.º 1
0
 public List <T> GetAllItems <T> () where T : class, new()
 {
     lock (SqlLock) {
         try {
             return(_dbConnection.Table <T> ().ToList());
         } catch (Exception ex) {
             throw MomSqlException.ToMomException(ex, "GetAllItems");
         }
     }
 }
Exemplo n.º 2
0
 public T GetItemById <T> (int id) where T : class, new()
 {
     lock (SqlLock) {
         try {
             return(_dbConnection.Get <T> (id));
         } catch (Exception ex) {
             throw MomSqlException.ToMomException(ex, "GetItemById");
         }
     }
 }
Exemplo n.º 3
0
 public void CleanupDB()
 {
     lock (SqlLock) {
         try {
             ResetTable <Settings> ();
             //add more tables here
         } catch (Exception ex) {
             throw MomSqlException.ToMomException(ex, "CleanupDB");
         }
     }
 }
Exemplo n.º 4
0
 public int ResetTable <T> () where T : class, new()
 {
     lock (SqlLock) {
         try {
             int ret = _dbConnection.DropTable <T> ();
             ret += _dbConnection.CreateTable <T> ();
             return(ret);
         } catch (Exception ex) {
             throw MomSqlException.ToMomException(ex, "ResetTable");
         }
     }
 }
Exemplo n.º 5
0
 public void RemoveItem <T> (int id) where T : class, new()
 {
     lock (SqlLock) {
         try {
             int ret = _dbConnection.Delete <T> (id);
             if (ret < 1)
             {
                 throw new MomSqlException("Could not insert item");
             }
         } catch (Exception ex) {
             throw MomSqlException.ToMomException(ex, "RemoveItem");
         }
     }
 }
Exemplo n.º 6
0
 public void InsertOrUpdateItem <T> (T item) where T : class, new()
 {
     lock (SqlLock) {
         try {
             int ret = _dbConnection.InsertOrReplace(item);
             if (ret < 1)
             {
                 throw new MomSqlException("Could not insert item");
             }
         } catch (Exception ex) {
             throw MomSqlException.ToMomException(ex, "InsertOrUpdateItem");
         }
     }
 }