Tuesday, May 31, 2011

Well, I'll be a master of EF4 when this is all said and done

I apparently have fallen prey for a classic Entity Framework 'gotcha'.  Null ObjectContext and needing to play with EntityKeys.  Not quite sure how to do it with an EntityCollection, so, like always, I posted the details on Stack Overflow: http://stackoverflow.com/questions/6195167/problems-trying-to-attach-a-new-ef4-entity-to-objectcontext-while-its-entity-coll

Monday, May 23, 2011

Different day, same problem, maybe some hope

I'm still facing the same problem which plagued me last week.  My form is somewhat complex - several textboxes, one text area, two dropdowns, more than ten checkboxes, one textarea, and two file upload inputs.  The edit model which I'm trying to bind all of that stuff to does not map 1:1 with my entity.  I've been looking at AutoMapper as a possible solution, but since my entity is actually an entity map (it contains a many-to-many relationship, which is what the checkboxes are for), there's some extra complexity which is tripping me up.

My plan, right now, is to give AutoMapper access to my repository so it can build the map.  Hopefully, all I'll need to do when I call Save() is attach the newly mapped object to the context and save it.

Of course, there are still the files to save, but that seems a bit more straightforward than the entity map.

Link to my Stack Overflow question: http://stackoverflow.com/questions/6062914/asp-net-mvc-2-and-automapper-dissecting-and-mapping-uploaded-file-info-with-aut

Thursday, May 19, 2011

SoC: Yeah, you know me!

Wondering if there's a graceful way to handle something that, on the surface, would break SoC.  Short version: I have an edit model I want to pass into my repo's validator, but I don't want the repo to have a reference to the edit model, as the repo is part of the domain and the model is with the UI.  Details and code here: http://stackoverflow.com/questions/6062914/asp-net-mvc-design-question-input-edit-model-reference-in-the-domain

So, nerd collective, how badly have I designed my code?

Tuesday, May 17, 2011

Still alive (insert witty Portal reference HERE)

Yeah, so I'm still alive.  Some distractions have come up, so my progress has come to a screeching halt.  Thankfully, it looks like most of what I have left to do before release is the small, tedious stuff.  Fleshing out a controller here, making some views there.  Nothing I can't handle, and certainly nothing complicated.  All of that was taken care of (with the customary amount of kicking and screaming on my end) at the beginning.  My little 404 detour was the last of the hard stuff, and something I didn't anticipate.

Like any good nerd, I already have a growing list of things to put in version 2 of the site, including:
  • Revamped layout
  • Redesigned database structure (nothing too drastic, just some refinement to make my queries simpler)
  • Full text search with Lucene.NET
  • Comment system
  • Online forums?
My immediate concern is handling file uploads.  It seems simple enough (I'm basing what I'm trying to do off a tutorial by Phil Haack: http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx), at least on the surface.  Hopefully the new edit model I'm almost done writing will work as expected.  If not, I can work around it until I can find a better solution to implement in version 2.

In any event, it looks like mostly smooth sailing until I actually upload this sucker to the live environment.  I'm sure that will be an experience.