/// Tuesday, November 29

Gamba: Data

As I thought more about a data access layer for Gamba, my ever flickering idea light came on and the solution was right in front of me. One of the goals of Gamba is to use Boo for everything, configuration, templates and so on. Why not use the CodeInjection library to simplify data access?

No matter which data access library is used, the library has to be told via a metadata file what data is queried and how to map those results to objects. (The exception being code generators which may need as little info as a connection string.) With the magic of CodeInjection metadata files can be transformed into managed code. And thus the genesis of Boo Data Templates.

Some advantages:


Boo Data Templates

Here's the bird's eye view of Boo Data Templates:

Each template contains a query and possibly a map definition if the result of the query is to be mapped to properties of the class. The templates are injected into Person via the MixinDataTemplates attribute. As an example, the Person.SelectAll.bdt template contains this:

    Select = "select person_name, person_gender from person"

    Name = person_name
    Gender = person_gender

The class which uses the template looks like this:

class Person:

    _name = ""

    _gender = "M"

After compilation, the class looks like this:

class Person:
    _name = ""

    _gender = "M"

    def SelectAll() as (Person):
        people = ExecuteQuery(queryFromTemplate)

        for p in people:
            person = Person()
            person.Name = people['person_name']
            person.Gender = people['person_gender']

    def Find(key) as Person:

    def Update():

Next Steps

Cameron Kenneth Knight (ckknight) is taking this idea forward. This will be a very nice data layer. More details will come as the library progresses.


Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?