コード例 #1
0
        public IEnumerable <Toy> GetToysForChild(Child kid)
        {
            var toys = new List <Toy>();

            _db.Query($"SELECT * FROM Toys WHERE ChildId = {kid.Id}",
                      (SqlDataReader reader) => {
                while (reader.Read())
                {
                    toys.Add(new Toy()
                    {
                        Id      = reader.GetInt32(0),
                        Name    = reader[1].ToString(),
                        ChildId = reader.GetInt32(2)
                    });
                }
            });
            return(toys);
        }
コード例 #2
0
        public List <Child> GetChildren()
        {
            _db.Query("select id, name, delivered from child",
                      (SqliteDataReader reader) => {
                _children.Clear();
                while (reader.Read())
                {
                    _children.Add(new Child()
                    {
                        id        = reader.GetInt32(0),
                        name      = reader[1].ToString(),
                        delivered = reader.GetInt32(2) == 1
                    });
                }
            }
                      );

            return(_children);
        }