Can't convert data retrieved from datasets to a model type ienumerables

I always get the error-- cannot convert to 'MvcMusicStore.Models.MusicStore.GenreDataTable' to 'System.Collections.Generic.IEnumerable' I am pasting my code below the controller:

using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using MvcMusicStore.Models;

  namespace MvcMusicStore.Controllers
  public class StoreController : Controller

    // GET: /Store/
    public ActionResult Index()
         MvcMusicStore.Models.MusicStoreTableAdapters.GenreTableAdapter ta= new Models.MusicStoreTableAdapters.GenreTableAdapter();
         var genres = ta.GetData().AsEnumerable();
         return View(genres);

my model:

namespace MvcMusicStore.Models
public partial class Genre
    public int GenreId { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public List<Album> Albums { get; set; }


and at last the view:

@model IEnumerable<MvcMusicStore.Models.Genre>

ViewBag.Title = "Index";

<h3>Browse Genres</h3>
Select from @Model.Count()
@foreach (var genre in Model)
"Browse", new { genre = genre.Name })</li>



It looks like ta.GetData() is not returning an object that can be cast into an IEnumerable<Genre>. Based on the error message it seems that ta.GetData() is returning a GenreDataTable object. If that is correct, I see a couple of things:

  1. In the Razor view, the model is looking for a IEnumerable of Genre objects not a GenreDataTable object.
  2. If your GenreDataTable object is already a collection, then have that as the return model instead of the IEnumerable.
  3. If GenreDataTable is not a collection of Genre objects, then you've got to either update the required model in the Razor view, or update the controller code to create the required type to match the model.

Need Your Help

bash: merging and sorting files

bash sorting

For example i have 2 files

iOS Region Monitoring: Is my app crashing or is this expected?

ios ios7 background cllocationmanager clregion

My app uses region monitoring when it is backgrounded. As soon as the app enters the background I take their location (which I already have in the foreground) and create a region around it and start