tags:

views:

236

answers:

1

I have setup a new ASP.NET MVC project and followed the SimpleRepository tutorial by:

  1. Adding the reference to SubSonic.Core (v3)
  2. Created a simple POCO - PhoneType
  3. Created the controller and injected the SimpleRepository
  4. Created the "Create" view

When I ran the sample, I get the following error:

The model item passed into the dictionary is of type 'SubSonic.Linq.Structure.Query`1[SubSonicMVC.Models.PhoneType]' but this dictionary requires a model item of type 'SubSonicMVC.Models.PhoneType'.

I compared my project to the Example that comes with SubSonic3. The only thing I did not change is the view page inheritence:

Inherits="System.Web.Mvc.ViewPage<SubSonicMVC.Models.PhoneType>"

What am I missing??

A: 

You're definitely looking in the right place. Change your "Inherits" to look like this:

Inherits="System.Web.Mvc.ViewPage<IEnumerable<SubSonicMVC.Models.PhoneType>>"

I ran into the same problem, except I had "IList" in place of the "IEnumerable" above... and that didn't work either. Turns out that SubSonic returns an "IQueryable", so that's why you have to use the "IEnumerable" in the view.

Hope that helps. Chad

leftend