views:

129

answers:

3

I have a couple of super simple databases. Basically they all consist of single tables that saves tracking/logging data etc.

Now I want to list this data but I'd like to find a solution that's applicable to all the different tables in all the databses. SO basically I'm looking for some way/some pattern of pointing a solution to a database, generate code and GUI and the publish the site. The tables can have huge amount of rows so I need functionally like paging etc but otherwise a simple list is all I'm looking for as a first step. I've been looking at Dynamic Data from MS - could this work? Other options? I'd really like the web sites to me ASP.NET MVC ...

As a seconds step I'd also like to have the possibility to change/add and delete data from the rows via the GUI.

+2  A: 

Consider using ASP.NET MVC 2. It has extensive scaffolding capabilities that can auto-generate the views for you, yet allows a lot of fine tuning

Brad Wilson explains scaffolding here: http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-1-introduction.html

For MVC 2, see http://aspnet.codeplex.com/ and http://www.asp.net/mvc/download/

Paging is not included, but you can get that from MVCContrib, for example

mnemosyn
+1  A: 

You could roll your own scaffolding and generate the actual pages using T4 (http://www.olegsych.com/2007/12/how-to-create-a-simple-t4-template/ and others), or you could look into monorail (http://www.castleproject.org/monorail/index.html).

Palle Due Larsen
+1  A: 

If you don't mind mandatory JavaScript then I would suggest jqGrid. It should be very simple to enumerate tables, columns, and generate jqGrid's columns from it (colModel). You can see an example of how I do a similar thing here - it does almost exactly what you need but for classes, not database. So, you can't use the solution "as is" because it's for domain classes, but it is very close, you can take it as a base and rewrite JqGridExtensions.JqGridModel to process db table definition, not domain class definition.

If your site has to work without JavaScript, then either MVC v2 with scaffolding will work, or you can try S#arp Architecture which also includes its own scaffolding out of the box, that generates full CRUD model/controller/views/repositories/etc. The benefit here is that you will still work with classes, not datasets. However as far as I understand you'll have to define scaffolding manually for each entity - but since scaffolding is very flexible, I'm sure you can write Uber-Scaffolding class that will enumerate your database and spit out sub-scaffolding files or just call them right away. A quote:

you programmatically create an object called EntityScaffoldingDetails which holds details such as the entity name, the namespace, along with property details such as the property name, type, domain signature inclusion, attributes, default test values, and SQL generation details.

But, I better like the jqGrid way, because it's very easy to generate jqGrid model definition from the database schema which usually contains all the metadata. Of course, one can integrate S#arp scaffolding and jqGrid so that the first produces the latter. The benefit of scaffolding is that you have full control over the code, you can take it and tweak it. Because, you can't expect it to be 100% automatic - generator can't decide HasMany or ManyToMany, control type, hidden fields, etc. Of course you can use SQL metadata (properties maybe) to give hints for your scaffolding generator.

Now, if you need a ready out-of-the-box solution, I don't think there's one except for maybe commercial tools. The above will only allow you to assemble your own one. As for commercial tool, for example, Telerik Grid said to be able to "automatically infer its columns based on the properties of the data item it is bound to".

queen3