I am trying to get started learning MVC. I built the MVC Music Store project that I found on the Microsoft site. http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-1.
I got it working pretty well but I ran into trouble when I tried to modified it. I want to put the data in a separate project. I used Linq to Entities for the data access.
Here is my class to access the data
public class clsUtilities
{
Utilities.MVCMusicStoreEntities db = new Utilities.MVCMusicStoreEntities();
public object GetAlbums(string GenreName)
{
var query = from tags in db.vieAlbumArtists
where tags.GenreName.Equals(GenreName)
select tags;
return query;
}
}
In my Controller my code is
public ActionResult Browse2(string genre)
{
// retrieve Genre and its associated albums from the database
var genreModel = mcloUtilities.GetAlbums(genre);
return View(genreModel);
}
I generate a cshtml file in my view
@model Utilities.vieAlbumArtist
@{
ViewBag.Title = "Browse2";
}
This all compiles ok but when I run it I get:
The model item passed into the dictionary is of type System.Data.Objects.ObjectQuery'1[Utilities.vieAlbumArtist]
, but this dictionary requires a model item of type Utilities.vieAlbumArtist
.