Wednesday, May 23, 2007

* Jasper : On the fly data access using Entity Objects

Writing data access layer is mandatory activity of any database aware application development. But it also seems to be least interesting phase as it involves lot of repetitive code or the phase whose output is not a finished product and so does not mean much to external world. Over the period lot of techniques have evolved to minimize the efforts which are spent on developing the Data Access Layer like :

  • Generating code based on db schema.
  • Writing a generic data access layer which reads the queries and data object metadata from config files.

The ADO.NET team is working on a new technology which simplifies the things beyond the above two.

Microsoft Code Name "Jasper" is a new framework which utilizes the capabilities of LINQ and Entity Framework of ADO.NET to create data access classes on the fly without any generation of code which needs to be compiled.

Jasper can be configured either to emit types which are directly mapped to each table in database or emit types which represent the domain objects. The Entity Framework of forthcoming ADO.NET is utilized to provide O/R mapping.

As utilizing types which are created at runtime involves late binding, currently only Visual Basic 9 and IronPython1.1 are supported. Still some of the features of Jasper can be used using C# also which i will cover in coming posts.

The earliest "Jasper" can come out for production is as part of 2nd release of Orcas which will contain the Entity Framework.

Jasper will also support data binding with GUI controls.

Jasper April 2007 CTP is available for download and requires Visual Studio 'Orcas' beta .

Following pseudo code will give some idea about it works :

string connectionString = "Database connection details";

context = DynamicContext.CreateDynamicContext(connectionString);

Query1 = context.Table1

resultList = Query1.Where(column1="A");

foreach result in resultList

Print (result.column1)




No comments:

Post a Comment