CRM day 999999 - Buildprovider DAL - subsonic dal is not sufficent -

by Tom 22. February 2007 02:57

It's been really busy since my last post, but I can allready tell you that I did not make the deadline.

Instead of using the SubSonic framework, I have been developping my own framework using buildproviders. The subsonic framework seemed to have a few things that were not really natural/flexible enough for me.
My own project is still in development, but I can assure you that I currently only need to implement some finetuning and cleanups. Lack of time is the main issue here.

Just a few hints :

  • The model is built dynamically & based on the database structure and some default templates
  • No mapping code required to start using the objects
  • Inheritance is derived from the database model (some conventions need to be followed)
  • The model supports intellisense
  • DSL-like language with syntax-checking to create queries.
  • The DAL only updates the fields that have changed, so no unnecessary updates
  • The DAL supports updates and deletes using where clauses (like SQL)
  • The DAL uses an SQL-Like syntax, see below !!!

Just to give you another clue, here's a question I got from somebody online (in Dutch).
(The explanation is also in Dutch, but since you can see the code (in bold) you can make your own mind up.)

>Hallo Tom,
>
>Momenteel ben ik bezig met mijn afstudeerproject voor mijn studie  
>Informatica (HBO NL).
>Het afstudeerproject gaat over het maken van een DSL in JRuby/Ruby,
>het  zelfde onderwerp waar jij in 2005 een topic over opende bij
>tweakers.net.
>(http://gathering.tweakers.net/forum/list_messages/1047491///dsl%2Cruby)
>Ik vroeg mij af of je er nog verder mee bent gegaan en wat je
>ervaringen  hierbij zijn.
>
>Alle suggesties, tips en hints zijn welkom.
>
>Ik hoop snel wat van je te horen.
>
>
>Met vriendelijke groet,
>
>Arjan Blom


And my response to it :

Hey Arjan,Sorry dat ik zo laat reply, maar mijn hotmail-adres controleer ik maar sporadisch eens.

Uiteindelijk heb ik voor dat project een simpele DAL icm c# gebruikt, aangezien een DSL niet haalbaar was binnen het gestelde budget en de termijn.

Momenteel ben ik voor een ander project de route van c# verder aan het volgen, maar het gaat eigenlijk niet echt meer om een DSL, eerder een soort van automatisch gegenereerde DAL/objectlayer .
Een voorbeeld :List<Person> l = Model.Person.Fetch(Db.Person.Name.Like("Arj*").And(Db.Person.DateOfBirth > #1/1/1980#));
Console.WriteLine(l.Count);
Person p = l[0];
Console.WriteLine(p.Address.City.Name);
p.Status = PersonStatus.Fetch(db.PersonStatus.Name="VIP");

Je kan makkelijk de functionaliteit van de classes uitbreiden, omdat ze partial & afgeleid zijn :
class Model
{
   public partial class Person : _Person
   {
      public override void Save()
      {
         if (DateOfBirth == null)
           throw new Exception("Date of birth is not set");
         base.Save();
      }
   }
}
En dan : 

p = new Person(); // bewaart automatisch de oude
p.FirstName = "Tom";
p.LastName = "Janssens";
p.Save();  // throws error : Date of birth not set

Het speciale aan dit model is dat het dynamisch gegenereerd wordt aan de hand van een database die volgens bepaalde regels opgebouwd is (dmv een buildprovider).
Uit de structuur van de database wordt dan een reeks klassen afgeleid (met inheritance), en deze worden dan middels een DAL opgehaald, alhoewel je deze misschien ook wel een DSL zou kunnen noemen.

Een voorbeeld :

Db.Select(db.Person.FirstName,db.Person.LastName,Invoice.LogicalId)
  .Tables(db.Person,db.Invoice)
  .Where(db.Person.Id == db.Invoice.PersonId)
    .And(db.Invoice.InvoiceDate < DateTime.Now.AddYears(-1)
  .OrderBy(db.Invoice.InvoiceDate)
  .Execute(oledbconnection)

Zoals je ziet benadert dit eerder de sql-syntax dan de c#syntax, terwijl dit wel nog voldoet aan de conventies van c#.

Ik vrees dus dat ik je neit echt verder zal kunnen helpen, maar wens je veel succes met je project.

Mvg,
Tom


Maybe (MAYBE) I'll release it on CodePlex if there are enough people asking the source... :P

Bookmark and Share

Tags:

Development

Comments

6/5/2007 11:46:10 PM #

Count one vote for source on CodePlex. This looks really interesting and I too have looked at SubSonic as well as numerous other DAL implementations for .NET. And even though I picked a particular solution I'm still looking for interesting implementations.

www.stevetrefethen.com/.../...TheNETFramework.aspx

Steve Trefethen |

6/6/2007 6:42:46 AM #

Tom Janssens

Steven,
Thanks for the vote... The article you referred to was a nice read.

What has been the final framework you have chosen ?

Tom

Tom Janssens |

Comments are closed

About me

Tom Janssens op LinkedIn

Tom Janssens op twitter

Core bvba RSS

My name is Tom Janssens and I am the owner of Core bvba, a software and consultancy company.
I am married to Liesbeth and have 2 sons named Quinten and Matisse.
ICT is both my job and passion.
Next to this my other hobby is actively playing music (mostly guitar), and I am also a lousy poker player.

I am also the founder of the following LinkedIn groups:
BDD Professional
Asp.Net MVC professional

More info about me and my company...