views:

72

answers:

1

So, here I am, about to roll my own data access layer. The key features that I needed in my DAL are asynchronous programming model, cloud based databases (eventual consistency, caching, REST protocols etc), multi-valued attributes, retrieving partial objects etc. I need to provide rich support for object oriented access - lists, dictionaries, serializable types etc. I am not looking at generating OO classes from an existing data-model. That is not how we design our apps, at least in this case. I am convinced that I would need to write my own DAL as to my knowledge, none out there suit my needs.

I am now confronted with the problem of designing a good query language that works on objects (hierarchical, lists, nested etc). Is there any good design/query processor out there that I can reuse?

Am I reinventing something that is already available? Or going down the right path?

+1  A: 

If you are using .NET, you can implement your own LINQ provider to get an in-language query language that is both constructable (by building functions or expressions) and readable.

I've implemented a couple of custom LINQ providers now, once you get past the initial learning curve I've found it to be extremely natural. Also, if you have any background in functional languages it will likely be very familiar.

Here's a tutorial to get started with:

http://weblogs.asp.net/mehfuzh/archive/2007/10/04/writing-custom-linq-provider.aspx

Alternatively you could write a custom query DSL. If you take this route I'd recommend considering using Boo to implement the language, or the excellent upcomming MGrammar language from the Oslo project.

Example Boo DSL:

http://nathan.whiteboard-it.com/archive/2008/06/24/settings-dsl.aspx

DSL with MGrammar:

http://msdn.microsoft.com/en-us/library/dd857654(VS.85).aspx

free-dom
While this answer is not exactly what I was looking for, I am choosing to accept this as an answer because of the pointers to DSL. I would however think about implementing a minimalist SQL like query construct to support my DAL and abstract from all providers. Overtime, I could enhance this query syntax and provide support for complex operations that the underlying provider supports.
Charles Prakash Dasari