/// <summary>
        /// This method gets all albums from the database
        /// </summary>
        private void GetAllAlbums()
        {
            using (MusicStoreContext dataSource = new MusicStoreContext())
            {
                //Query the Album Table using EF and LINQ
                var albums = (from allAlbums in dataSource.Albums
                              select allAlbums);

                AlbamDataList.DataSource = albums.ToList();

                // bind the result to the Album GridView
                AlbamDataList.DataBind();
            }
        }
Пример #2
0
        /// <summary>
        /// This Method gets the products data from the DataBase
        /// </summary>

        /*private void getMusicItem()
         * {
         *  using (MusicStoreContext dataSource = new MusicStoreContext())
         *  {
         *      //Query the Album Table using EF and LINQ
         *      var albums = (from allAlbums in dataSource.Albums
         *                      select allAlbums);
         *      // bind the result to the Album GridView
         *      MusicGridView.DataSource = albums.ToList();
         *
         *      ///MusicGridView.DataSource = albums.AsQueryable().OrderBy(SortString).ToList();
         *      MusicGridView.DataBind();
         *  }
         * }*/
        private void getMusicItem()
        {
            int GenreId = Convert.ToInt32(Request.QueryString["GenreId"]);

            using (MusicStoreContext dataSource = new MusicStoreContext())
            {
                //Query the Album Table using EF and LINQ
                var albums = (from allAlbums in dataSource.Albums where allAlbums.GenreId == GenreId
                              select allAlbums);
                // bind the result to the Album GridView
                AlbamDataList.DataSource = albums.ToList();

                ///MusicGridView.DataSource = albums.AsQueryable().OrderBy(SortString).ToList();
                AlbamDataList.DataBind();
            }
        }