I am trying to bind to a rather large SQL database table with over 100 fields. I’m doing basic CRUD operations, and when it comes to editing, I’ve decided to split up the editing into two pages (Views), just to keep the page lengths manageable and user-friendly. I’m using MVC 3 (C#) with the Entity Framework to map the database.
My question – how do I bind to “half” of this table in each ActionResult? There are two issues – I am validating most of the inputs using a partial class and the MetadataType attribute. How do I split up the validations so that one page is not validating fields for the other? Secondly, how do I bind to only half of the properties of the table? Many are non-nullable and would trigger database errors if they attempted to bind without corresponding form inputs.
I know I could use [Bind(Include=”…”)] or [Bind(Exclude=”…”)] in my two ActionResults, but it seems pretty illogical and non-DRY to list 50 individual fields in an include or exclude tag. Is there a better way to do this?
I think I may have misunderstood this… after testing it looks like the MVC model binding allows for partial binding after all.