views:

277

answers:

6

I am developing an application for which I want to expose the basic CRUD operations on most of the database entities through REST web services. A colleague has demonstrated some impressive code generation using Grails.

I would like to be able to generate my REST services as well, but using ASP.NET MVC instead of Grails. I planning on using Fluent-NHibernate for the ORM. The underlying database is PostgreSQL.

Are there any tools available that would assist me in generating the REST services in ASP.NET MVC from the domain objects?

+2  A: 

You should check out T4 templates.

Jason Punyon
+1  A: 

It sounds like a really good project for S#arp Architecture. That is a nice framework built to help make putting together CRUD operations with ASP.NET MVC and NHibernate. It does also make use of T4 as was suggested for use by Jason but they have done the legwork for you really and wrapped everything up in a nice package.

mockedobject
+1  A: 

Have you looked at Ado.Net Data Services (aka Astoria)? It does pretty much what you are looking for.

Darrel Miller
A: 

You may also want to keep an eye on ABSE (http://www.abse.info). ABSE is a code-generation and model-driven software development methodology that is completely agnostic in terms of platform and language, so you wouldn't have any trouble creating your own generators for ASP.NET MVC.

Unfortunately, ABSE is still work in progress and a reference IDE (AtomWeaver) is still in the making... but still worth a look in your case.

Rui Curado
+1  A: 

Take a look at the REST Services for asp.net MVC library.

To get an API that supports html, JSON and XML "out of the box", just decorate your controller with [WebApiEnabled], like this:

using System.Web.Mvc.Resources;

namespace ivu.Controllers
{
    [WebApiEnabled]
    public class LocationsController : Controller
    {
        public ActionResult Index()
        {
            return View(db.ReadLocations().ToList());
        }
    }
}
BenB
A: 

Or take a look at my series of articles at http://www.shouldersofgiants.co.uk/Blog where I create a framework that adds REST support to ASP.Net MVC

Piers Lawson