views:

92

answers:

2

I've been looking around for a simple solution to this, trying my best to lean towards something like NHibernate, but so far everything I've found seems to be trying to solve a slightly different problem. Here's what I'm looking at in my current project:

We have an IBM iSeries database as a primary repository for a third party software suite used for our core business (a financial institution). Part of what my team does is write applications that report on or key off of a lot of this data in some way. In the past, we've been manually creating ADO .NET connections (we're using .NET 3.5 and Visual Studio 2008, by the way) and manually writing queries, etc.

Moving forward, I'd like to simplify the process of getting data from there for the development team. Rather than creating connections and queries and all that each time, I'd much rather a developer be able to simply do something like this:

var something = (from t in TableName select t);

And, ideally, they'd just get some IQueryable or IEnumerable of generated entities. This would be done inside a new domain core that I'm building where these entities would live and the applications would interface with it through a request/response service layer.

A few things to note are:

  1. The entities that correspond to the database tables should be generated once and we'd prefer to manually keep them updated over time. That is, if columns/tables are added to the database then we shouldn't have to do anything. (If some are deleted, of course, it will break, but that's fine.) But if we need to use a new column, we should be able to just add it to the necessary class(es) without having to re-gen the whole thing.
  2. The whole thing should be SELECT-only. We're not doing a full DAL here because we don't want to be able to break anything in the database (even accidentally).
  3. We don't need any kind of mapping between our domain objects and the generated entity types. The domain barely covers a fraction of the data that's in there, most of it we'll never need, and we would rather just create re-usable maps manually over time. I already have a logical separation for the DAL where my "repository" classes return domain objects, I'm just looking for a better alternative to manual ADO to be used inside the repository classes.

Any suggestions? It seems like what I'm doing is just enough outside the normal demand for DAL/ORM tools/tutorials online that I haven't been able to find anything. Or maybe I'm just overlooking something obvious?

+1  A: 

You might want to investigate this:

http://www.codesmithtools.com/

I've been on a few projects where this tool was used, and the developers were fond of it.

Warning: it's not freeware.

code4life
+1: A very early version of this (2.6) is freely available, works well but has a dependency on .net 1.1.
Binary Worrier
I've actually used 2.6 in the past and wasn't particularly thrilled with it. It might be worth re-visiting if I can write a decent template for it.
David
A: 

Adding to code4life's answer.

I recently used CodeSmith 2.6 on a pet project at home.
I tailored the templates to generate Partial classes with partial CRUD methods.
I then extended the partial classes and partial methods to provide basic mapping e.g. when "Order" is read, read the associated "OrderLines" etc.

A similar approach might work for you, and be simpler because really, you only want the R of CRUD :)

Hope this helps.

P.S. I need to switch from CS 2.6 to something else (possibly MyGeneration), as 2.6 is dependant on .Net 1.1, which is a problem as I'm moving to a 64 development machine.

UPDATE

I hear ya.
Have a good poke a MyGeneration mate, we use CodeSmith here in work, which is why I went for 2.6 at home (I'd a quick glance at MyGeneration, didn't get it immediately - which was more time than I had to give it - so switched back to CS).

MyGeneration is basically an open source version of CS.

Also, why not get it to generate the code ALWAYS - you can tweak to your hearts content with Partial Classes & Partial Methods, I know you think re-generating is overkill, but experience tells me it's one of those things that if you don't it have you'll need it, where as if you have it and need it you'll never notice.

Binary Worrier
It may come to that for my needs, but I'm hoping to avoid it. The 1.1 dependency _shouldn't_ be a problem if I just generate the code once and manually tweak it moving forward, but that's a big "if" at this point. And I'm really watching my step here because whatever I implement could very easily become etched in stone and become "the way it's done" for the next few years.
David