Search code examples
.netasp.net-mvc-3naked-objects

How to do Naked Objects .NET MVC without persistence


I'm looking to re-write an admin app, and I already have a pretty clean domain class library and web services/databases to handle all the business logic and persistence. That is, the library already provides CreateFoo, GetFoo, and UpdateFoo methods, that by default use existing web services.

I thought I might use Naked Objects for .NET MVC to write a new web admin tool. It seems like Naked Objects assumes that you want the Naked Objects framework to handle both GUI and persistence, but I just want the MVC web site to come from Naked Objects, not the persistence.

Is there any guidance on how to do GUI-only Naked Objects for .NET? How do I "turn off" the persistence side altogether? If I just try it, I get an exception "No entity connection strings in App.config file"--of course, I don't want to use any connection strings.

UPDATE: Injecting a new NakedObjects.Persistor.Objectstore.Inmemory.InMemoryObjectPersistorInstaller into the Persistor property in RunWeb.cs seemed to switch me over to in-memory persistence. Diving a little deeper, it seems as though I might need to implement more complicated interfaces--thus the need for a guide. Maybe it isn't worth using Naked Objects for applications where we would have to wire up all the persistence logic to fit Naked Objects's interfaces?


Solution

  • As you say, you can use NO MVC with the in-memory object store. You need to override

    protected override IObjectPersistorInstaller Persistor
    

    property in the RunWeb class.

    But the objects have to come from somewhere. In the case of the in-memory object store, the other installer to look for is the IFixturesInstaller, which defines a set of fixtures (entities) to install into the in-memory objectstore on startup.

    Overall, though, it maybe that your use case doesn't particularly fit what NO MVC was designed to do.