Exemple #1
0
 public void WriteNewFeedToFeedsDataBase(string title, string url)
 {
     using (var db = new FeedContext())
     {
         var feed = new Feed { Title = title, URL = url };
         db.Feeds.Add(feed);
         db.SaveChanges();
     }
 }
Exemple #2
0
        private void PopulateFeedsDropDown()
        {
            //Should add to DataAccess but having problems with the return of a List<anonymous> tipe.
            using (var db = new FeedContext())
            {
                var q = (from b in db.Feeds
                         orderby b.Title
                         select new { Title = b.Title, Url = b.URL }).ToList();

                if (q != null)
                {
                    dropdownFeeds.DataSource = q;
                    dropdownFeeds.DataTextField = "Title";
                    dropdownFeeds.DataValueField = "Url";
                    dropdownFeeds.DataBind();
                    dropdownFeeds.Items.Insert(0, new ListItem("None", "0"));
                }
            }
        }