tags:

views:

20

answers:

1

I'm working in ASP.NET in an application where often users want to add fields or change field names.

I'd like to be able to have an xml schema in place that is parsed and a dynamic object model created from it that can be accessed throughout the application.

My initial reaction is that this is not realistic. I think there is flexibility about the dynamic nature of it. I think the people I'm trying to build this for wouldn't mind recompiling.

Even if the app recompiled, I don't know how to abstract away enough in my code access the data to allow for users changing property names, etc. How can you write LINQ when the properties might change?

In short, there's two questions here: 1) is there a way to dynamically generate an object model of the database and 2) is there a way to abstract away enough so that code accessing the database doesn't break when properties change?

A: 

1) is there a way to dynamically generate an object model of the database

Yes

2) is there a way to abstract away enough so that code accessing the database doesn't break when properties change?

Yes

But, you don't want an ORM for this scenario. You may not even want a relational database, since a relational database won't be doing much for you.

You may want to look into a document or object database. Finding one that supports Linq will be difficult.

Fundamentally, you and your customers have to understand this isn't a traditional relational database app. You are building something that has been built before, but not ever really in a mainstream way. You will likely be breaking new ground more often than reusing off the shelf technology and patterns.

It can be a fun project if you enjoy the novel aspects of it or it can be a nightmare if your customers expect the solution to be as easy and off the shelf as a standard relational solution.

Michael Maddox
So you're saying it would need to parse XML? How would you get around the fact that whatever classes you needed to wrap the data source would change when the schema changes? Wouldn't that require recompilation?
rsteckly
I didn't say anything about parsing XML. If the code around your data source is generic enough, you won't need to recompile it when the schema changes. I think you need to prototype some solutions so you can get a better feel for the technical requirements.
Michael Maddox