// For converting types after retrieving from database public NewsArticle(DBNewsArticle article) { Title = article.Title; Description = article.Description; Url = article.Url; UrlToImage = article.UrlToImage; Source = new NewsSource(); Source.ID = article.SourceID; Source.Name = article.SourceName; }
/** * Deletes old articles and adds new ones to the database */ public void AddNewClusters(Cluster[] clusters) { // Delete old ones then add new ones conn.Query <DBNewsArticle>("DELETE FROM NewsArticles"); for (int i = 0; i < 3; i++) { int j = 0; foreach (var article in clusters[i].Articles) { var dbArticle = new DBNewsArticle(article, i); conn.Insert(dbArticle); j++; if (j >= 6) { break; // Store max of 6 articles to prevent taking too long to load each time } } } }