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

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 |

About Tom

Tom Janssens op LinkedIn

Tom Janssens op twitter

Core bvba RSS

 

Tom Janssens is an independent freelance ICT consultant that has been "into computers" ever since the age of 7.

Typing source code from a book evolved into exploring the limits of coding in procedural, assembly and object-oriented languages.
As he matured in software coding, he started focussing on the problems surrounding software development, and learned that software development is usually about people and interactions first, and about technology second.

Due to his diverse track record he gained insights in a lot of aspects of the software development process. Currently his main focus is on strategic ICT advice, lean product/project development and improving the software development process and architecture.

He avoids ivory-tower-approaches by applying and verifying the applicability of the latest tech buzz in software experiments.

He is also the founder of the following LinkedIn groups:

CQRS Professional
BDD Professional
Asp.Net MVC professional

More info about Tom and his company...


Advertisement

Forget all your SCRUM -, Kanban - and other Agile and Lean certificates

Here is the only true AGILE and LEAN certificate you will ever need:

The Creative Recursive Analysis Process Certificate
(CRAP Certificate for short)

More info can be found at the official CRAP certificate website:
http://bit.ly/CRAPCertificate