Simple CRUD ToDo List with Dapper


This entry is part 5 of 5 in the series Dapper

We have a short series of posts here that show the listings for a simple WPF ToDo list program. In that program we use SQLite and Dapper. There is a class called SQLiteDataAccess that stores our routines that access and manipulate the data in the database. To see the code listing for that file, go to WPF ToDo Version 2 at the bottom.

Below are the four most important lines of code in that SQLiteDataAccess.cs file of ToDo Version 2. The only one we don’t have here is the query that selects exactly one row.

  • var output = conn.Query(“select * from ToDos order by Id desc”, new DynamicParameters());
  • conn.Execute(“insert into ToDos (Name, Status) values (@Name, @Status)”, todo);
  • conn.Execute(“update ToDos set Name = @Name, Status = @Status where Id = @Id”, todo);
  • conn.Execute(“delete from ToDos where id = @Id”, new { Id = todo });
Series Navigation<< Dapper Installation into your Project in Visual Studio