コード例 #1
0
        public IEnumerable <TaskItem> GetAll()
        {
            NpgsqlCommand command = new NpgsqlCommand("select id, title, " +
                                                      "is_done, list_id from tasks", conn);

            using (NpgsqlDataReader dr = command.ExecuteReader())
            {
                while (dr.Read())
                {
                    yield return(TaskMapper.map(dr));
                }
            }
        }
コード例 #2
0
        public IEnumerable <TaskItem> GetByListId(long listId)
        {
            NpgsqlCommand command = new NpgsqlCommand("select id, title, " +
                                                      "is_done, list_id from tasks where list_id = @list_id", conn);

            command.Parameters.AddWithValue("list_id", NpgsqlDbType.Bigint, listId);

            using (NpgsqlDataReader dr = command.ExecuteReader())
            {
                while (dr.Read())
                {
                    yield return(TaskMapper.map(dr));
                }
            }
        }