示例#1
0
 public int Insert <T>(string dbPath, T entity)
 {
     using (var db = SqliteCon.CreateConnection(dbPath))
     {
         return(db.Insert(entity));
     }
 }
示例#2
0
 public int Execute(string query, params object[] args)
 {
     using (var db = SqliteCon.CreateConnection(mainDbPath))
     {
         return(db.Execute(query, args));
     }
 }
示例#3
0
 public int Update <T>(string dbPath, T entity)
 {
     using (var db = SqliteCon.CreateConnection(dbPath))
     {
         return(db.Update(entity));
     }
 }
示例#4
0
 public List <T> GetEntityList <T>(string dbPath, string query, params object[] args) where T : new()
 {
     using (var db = SqliteCon.CreateConnection(dbPath))
     {
         return(db.Query <T>(query, args));
     }
 }
示例#5
0
 public int DeleteEntity(string dbPath, object objectToDelete)
 {
     using (var db = SqliteCon.CreateConnection(dbPath))
     {
         return(db.Delete(objectToDelete));
     }
 }
示例#6
0
 public int ExecuteScalar(string dbPath, string query, params object[] args)
 {
     using (var db = SqliteCon.CreateConnection(dbPath))
     {
         return(db.ExecuteScalar <int>(query, args));
     }
 }
示例#7
0
        public T GetEntity <T>(string DbPath, string query, params object[] args) where T : new()
        {
            T t = default(T);

            using (var db = SqliteCon.CreateConnection(DbPath))
            {
                t = db.Query <T>(query, args).FirstOrDefault();
            }
            return(t);
        }
示例#8
0
 public void ExecuteWithTransaction(List <string> sqls)
 {
     using (var db = SqliteCon.CreateConnection(mainDbPath))
     {
         try
         {
             db.BeginTransaction();
             foreach (var sql in sqls)
             {
                 db.Execute(sql);
             }
             db.Commit();
         }
         catch (System.Exception)
         {
             db.Rollback();
         }
     }
 }