Beispiel #1
0
 public Tag(string id, string name, Tag parentTag)
 {
     this.Id = id;
     this.Name = name;
     childTags = new List<Tag>();
     photos = new List<Photo>();
     this.parentTag = parentTag;
 }
        private void RetrieveRootTagsFromDatabase(SqliteConnection conn)
        {
            IDataReader reader = null;
            IDbCommand dbcmd = null;
            try
            {
                dbcmd = conn.CreateCommand();
                string sql =
                    "SELECT id, name " +
                        "FROM tags "+
                        "WHERE category_id = 0";
                dbcmd.CommandText = sql;

                reader = dbcmd.ExecuteReader();
                while(reader.Read()) {
                    string tagId = reader.GetValue (0).ToString();
                    string tagName = reader.GetValue (1).ToString();
                    Tag t = new Tag(tagId, tagName, null);
                    t.InitializeTag(conn);
                    rootTags.Add(t);
                }
                //populate the childs
                foreach ( Tag tag in  rootTags)
                {
                    tag.RetrieveChildTagsFromDatabase(conn);
                }
            }
            finally
            {
                // clean up
                reader.Close();
                reader = null;
                dbcmd.Dispose();
                dbcmd = null;

            }
        }