public BSet Create(BSet value) { string query = @" INSERT INTO bsets (title, descr) VALUES(@Title, @Description)"; int id = _db.ExecuteScalar <int>(query, value); value.Id = id; return(value); }
public BSet GetById(int id) { string query = "SELECT * FROM bsets WHERE id = @id"; BSet bset = _db.QueryFirstOrDefault <BSet>(query, new { id }); if (bset is null) { throw new Exception("Invalid Id"); } return(bset); }
public BSet Update(BSet value) { string query = @" UPDATE bset SET title = @Title WHERE id = @Id; SELECT * FROM bsets WHERE id = @Id"; return(_db.QueryFirstOrDefault <BSet>(query, value)); }