Beispiel #1
0
        public void Delete()
        {
            var cmd = SessionDatabase.CreateCommand();

            cmd.CommandText = "DELETE FROM sessions WHERE sessionid = @sessionid";
            cmd.Parameters.AddWithValue("@sessionid", SessionID);
            cmd.ExecuteNonQuery();
        }
Beispiel #2
0
        public string Get(string name)
        {
            var cmd = SessionDatabase.CreateCommand();

            cmd.CommandText = "SELECT value FROM sessions WHERE sessionid = @sessionid AND name = @name";
            cmd.Parameters.AddWithValue("@sessionid", SessionID);
            cmd.Parameters.AddWithValue("@name", name);
            var result = cmd.ExecuteScalar();

            return(result == null ? null : result.ToString());
        }
Beispiel #3
0
 public void Set(string name, string value)
 {
     if (value == null)
     {
         Delete(name);
     }
     else
     {
         var cmd = SessionDatabase.CreateCommand();
         cmd.CommandText = "INSERT OR REPLACE INTO sessions (sessionid, name, value) VALUES (@sessionid, @name, @value)";
         cmd.Parameters.AddWithValue("@sessionid", SessionID);
         cmd.Parameters.AddWithValue("@name", name);
         cmd.Parameters.AddWithValue("@value", value);
         cmd.ExecuteNonQuery();
     }
 }