public Int32 Insert(SimpleWithAutoincrementPrimary entry) { using SqliteCommand command = this.connection.CreateCommand(); command.CommandText = @"INSERT INTO SimpleWithAutoincrementPrimary (StringProperty) VALUES (@stringProperty); SELECT last_insert_rowid();"; command.Parameters.Add(new SqliteParameter("@stringProperty", entry.StringProperty ?? (object)DBNull.Value)); return((Int32)(long)command.ExecuteScalar()); }
public void Delete(SimpleWithAutoincrementPrimary entry) { using SqliteCommand command = this.connection.CreateCommand(); command.CommandText = @" DELETE FROM SimpleWithAutoincrementPrimary WHERE Id = @id"; command.Parameters.Add(new SqliteParameter("@id", entry.Id)); command.ExecuteNonQuery(); }
public void Update(SimpleWithAutoincrementPrimary entry) { using SqliteCommand command = this.connection.CreateCommand(); command.CommandText = @" UPDATE SimpleWithAutoincrementPrimary SET StringProperty = @stringProperty WHERE Id = @id"; command.Parameters.Add(new SqliteParameter("@id", entry.Id)); command.Parameters.Add(new SqliteParameter("@stringProperty", entry.StringProperty ?? (object)DBNull.Value)); command.ExecuteNonQuery(); }
public List <SimpleWithAutoincrementPrimary> Get(string filter = null) { using SqliteCommand command = this.connection.CreateCommand(); command.CommandText = @" SELECT Id, StringProperty FROM SimpleWithAutoincrementPrimary"; List <SimpleWithAutoincrementPrimary> result = new List <SimpleWithAutoincrementPrimary>(); if (!string.IsNullOrEmpty(filter)) { command.CommandText += "\nWHERE " + filter; } using SqliteDataReader reader = command.ExecuteReader(); while (reader.Read()) { SimpleWithAutoincrementPrimary entry = new SimpleWithAutoincrementPrimary(); entry.Id = reader.GetInt32(0); entry.StringProperty = reader.IsDBNull(1) ? null : reader.GetString(1); result.Add(entry); } return(result); }