Beispiel #1
0
 private void loadBlogEntries(int count)
 {
     blogEntries = new List <BlogEntry>();
     using (var connection = new MySqlConnection(connetionString))
         using (var command = connection.CreateCommand())
         {
             connection.Open();
             command.CommandText = $"SELECT * FROM cb_posts WHERE post_status LIKE 'publish' ORDER BY id DESC LIMIT 0, {count};";
             using (var reader = command.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     BlogEntry blogEntry = new BlogEntry(reader.GetString(4), reader.GetInt32(0))
                     {
                         Date    = reader.GetDateTime(2),
                         DateGMT = reader.GetDateTime(3),
                         Title   = reader.GetString(5),
                         Name    = reader.GetString(10),
                         GUID    = reader.GetString(19)
                     };
                     blogEntry.generateName();
                     blogEntries.Add(blogEntry);
                 }
                 connection.CloseAsync();
             }
             foreach (var blogEntry in blogEntries)
             {
                 blogEntry.TagIds = populateTagList(blogEntry.Id);
             }
         }
 }