MVC, LINQ, and WinHost

I love MVC. I recently had to make some changes to the swim team website to get ready for the 2011 season. Because there was a nice SOC enforced by MVC, I simply had to add a couple of new controllers with some basic CRUD:

clip_image001

add their associated views, and then wire up to my factory using my POCOs:

public ActionResult Index(int? page) { FamilyFactory familyFactory = new FamilyFactory(); IQueryable<Family> families = familyFactory.GetAllFamilies() .OrderBy(family => family.FamilyDesc) .AsQueryable <Family>(); const int pageSize = 10; var paginatedFamilies = new PaginatedList<Family>(families, page ?? 0, pageSize); return View(paginatedFamilies); }

(note that I used the paginated list from Nerd Dinner)

Boom goes the dynamite.

Upon reflection, you can really see how useful using POCOs are when you have to extend your application. That upfront cost 2 years ago is paying huge dividends now.

I did run into 1 small hiccup when I deployed to WinHost. I received the following error:

clip_image002

After some digging (this error does not Google well), I added this:

<trust level="Full" />

To System.Web and things corrected.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: