O/R Mapping for DataModels needed

It’s helpful that ESRI has provided data models for so many industries. Some of the data models, such as ArcHydro, also include tools that operate on the data.

But from what I can tell, there are no classes provided that address the so-called “object-relational impedance mismatch”.

This excerpt from Scott Ambler’s book describes the problem pretty well.

What I think we need are some baseclasses that do simple object-relational mapping. These baseclasses would be generated from a data model designer that would run within Visual Studio. In addition to generating xml schemas from which would could create geodatabases, the designer would also generate .NET code (C# or VB.NET) which we could then inherit from and override/extend to meet particular needs. Or maybe partial classes is the way to go, as Dave Bouwman describes here. Either way, we really need some way to create a library of .NET classes that work with each of these data models.

While COM will likely be around for a lot longer, I don’t see why we can’t use .NET classes to hide much of it. Implementation inheritance can be good – let’s allow programmers to leverage use it. Maybe the goals of custom features could be addressed by this approach without requiring C++ ATL.

For example, instead of using a featurecursor to loop through a StreamGauge featureclass, I’d like to simply get a System.Generic.Collection collection of StreamGauges with getters/setters mapped to each field of the feature.


4 comments so far

  1. Paolo on

    Hi Kirk
    have you seen this?

    not sure if NHibernate is what you are looking for, but it could be a possible approach not starting from scratch
    ciao 😉

  2. Dave on

    The code-gen solution we used worked really well – just design the geodatabase, and then rip the data access layer directly from it (from an Xml schema export). Unfortunately for us that IP stayed with our old employer, but the basic stuff is not really that hard – took about a week to design out how we wanted the classes to work, and then about 2 days with CodeSmith to build the code gen templates. From there it was an evolution to add in functionality as we needed it.

    The controls for data binding also took some time, but once you get to the point of drag & drop data bound development, it really pays back.

    I’m already over committed in terms of open-source projects, (http://www.arcdeveloper.net/Source.ashx) but others on my team may be willing to give some guidance. It could certainly be hosted at ArcDeveloper.net.



  3. Kirk on

    @Paolo – I hadn’t seen NHibernateSpatial. It looks interesting. I wonder if it would work with ESRI geodatabases. Regards, Kirk

    @Dave, yeah, the binding is really tricky … especially figuring out when to start and stop EditOperations for for commiting changes.

    Most of what I develop is owned by whatever client is paying. A few allow me to put it in the public domain, but they are the exception. If ESRI would provide the code generation tools, along with the baseclasses, I would more likely build on top of their data models. Or maybe ESRI could just provide some CodeSmith Templates.

    Regards, Kirk

  4. Derek Williams on

    I second Paolo’s suggestion, I use Hibernate for a large application (deployed for four years now :)) and have been pretty happy. Hibernate has a non trivial learning curve but is very powerful and well designed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: