Page 53, Brind, Spaanjaars, 2011 Webmatrix ...
CRUD - Pages in Webmatrix with the DRY principle, Don't Repeat yourself.
My website now has 12 tables and that will continue to grow as the needs of the website
continues to grow. Every table will require a AUD (Add,Update,Delete) maintenance page to
keep it current. In keeping with the recomendation of applying 'DRY', does anybody have a
favorite way to limit all the plumbing that will be necessary for the maintenance of tables.
My thought is to have a maintenance page, a grid, to list all the tables and the AUD pages:
Type | Name |Add (click) |Update (click)|Delete (Click)
---------------------------------------------------------------
Lookup | Status | AddStatus.cshtml | UpdtStatus | DelStatus
Lookup | Category | AddCat | UpdtCat | DelCat
Linked | Mem2Event| AddM2E | UpdtM2E | DelM2E
Linked | Mem2Deal | AddM2D | UpdtM2D | DelM2D
Process| Event | AddEvent | UpdtEvent | DelEvent
Process| Deal | AddDeal | UpdtDeal | DelDeal
With this approach I have at least 36 pages to build across 12 tables.
Surely there is a better approach that I can use within Webmatrix.
I don't tend to create "Delete" pages. I just add that as an option to the edit page as a general rule unless I want to give the user the ability to bulk delete something. That should reduce your code by a third. However, there is no shortcut for CRUD stuff.
Microsoft tried something along those lines with Dynamic Data, but it never really took off and seems to have died a death. It has a sub-forum here, but is not listed among the ASP.NET "Solutions" at the top of the page.
DMT20601
Member
86 Points
197 Posts
CRUD - DRY "Don't Repeat Yourself"
Dec 27, 2012 07:43 PM|LINK
wavemaster
Participant
1350 Points
1161 Posts
Re: CRUD - DRY "Don't Repeat Yourself"
Dec 27, 2012 07:51 PM|LINK
I have 21 tables and 50-60 pages.
The number of pages could probably be trimmed a bit, but I have chosen simplicity over over style.
Mikesdotnett...
All-Star
155597 Points
19981 Posts
Moderator
MVP
Re: CRUD - DRY "Don't Repeat Yourself"
Dec 27, 2012 09:48 PM|LINK
I don't tend to create "Delete" pages. I just add that as an option to the edit page as a general rule unless I want to give the user the ability to bulk delete something. That should reduce your code by a third. However, there is no shortcut for CRUD stuff. Microsoft tried something along those lines with Dynamic Data, but it never really took off and seems to have died a death. It has a sub-forum here, but is not listed among the ASP.NET "Solutions" at the top of the page.
Web Pages CMS | My Site | Twitter