Exemple #1
0
 public void ExecuteReader(string command, Action <DbDataReader> callback)
 {
     LolipopUtils.Debug("SQL Command", command);
     try
     {
         this.Connection?.Open();
         this.Command.CommandText = command;
         this.Command.Connection  = this.Connection;
         callback(this.Command.ExecuteReader());
     }
     catch (DbException)
     {
         throw;
     }
     finally
     {
         this.Connection?.Close();
     }
 }
Exemple #2
0
        public int ExecuteNonQuery(string command)
        {
            LolipopUtils.Debug("SQL Command", command);
            int result = -1;

            try
            {
                this.Connection?.Open();
                this.Command.CommandText = command;
                this.Command.Connection  = this.Connection;
                result = this.Command.ExecuteNonQuery();
            }
            catch (DbException)
            {
                throw;
            }
            finally
            {
                this.Connection?.Close();
            }
            return(result);
        }
Exemple #3
0
        public bool InsertOne(string table, object obj)
        {
            string command = $"insert into { table } ({ LolipopUtils.Join(",", this.MapPropertyKeys(obj)) }) values('{ LolipopUtils.Join("','", this.MapProperties(obj)) }')";

            return(this.ExecuteNonQuery(command) != -1);
        }