Greetings,
I am finishing a CSLA warpper around LLBL objects utilizing ADAPTER. The two actually complement each other so perfectly that you would think the FRANS & ROCKY collaborated on the design, but I think this a pay back of following well know design patterns.
Before explaining how to approach this you have to understand the general architecture. CSLA is based on the pricipal of exposing public sharedservices to the UI (this is an industry best practice as you would see browsing some of the threads here at the Architecture forum).
These service routines would call the client side DataPortal shared methods that decide to use either a local ServerDataPortal or a remote DataPortal (depending on the settings of your AppConfig or WebConfig). Once a ServerDataPortal method is called, it will use reflection with the help of the passed parameter (a criteria object or the BO object itself) to call the private methods of the business object in question (consult rocky's article at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet03262002.asp). These private methods would do the actual DataAccess work (be it ADO.NET or in our case LLBL code).
To make LLBL's entity classes use the data portal in this fasion is not all that difficult as long as you understand what the DataPortal is really doing:
1- What will be utilized from the CSLA solution is CSLA, ServerDataPortal, ServicedDataPortal and the WebPortal (the C# bindable stuff is not needed here). The main classes needed in the CSLA project are the DataPortal, BusinessIdentity and BusinessPrincipal (and any support classes they are using). The other classes (BusinessBase, ...etc.) are not usefull with LLBL. You should customize a CSLA solution by removing all the extra functionality and keeping what you will be using
2- Create a LLBL designer project (CSLA.DAL for example) for the security tables that will be utilized in the table security used in CSLA. The two generated projects will be added to the CSLA solution. These two projects will be referenced by the CSLA project only! (CSLA project will also need to refernce LLBL's ORMSupportClasses DLL)
3- get the "Extended entity generator templates for Adapter" (from the 3rd party download site at LLBLGEN). Use these templates when generating all projects to be used by the new framework (including the security tables from step 2).
This template generates extra classes in a folder (EntitySubClasses). These entity sub classes extend the entity classes generated by LLBL. These are going to be your Business Object classes.
For example, when generating code for the table security (to be used in the CSLA solution itself) you will copy the generated (EntitySubClasses) folder from the DBGeneric project to the CSLA project (if you used CSLA.DAL as the root namespace for the LLBL project, you have to modify the name space in these entity subclasses from CSLA.DAL to just DAL). you must also copy the DeriveEntityFactory class from that project to the CSLA project also (remeber to adjust the namespace here and to remove these classes from the DBGeneric project).
Now, all you table security code in BusinessIdentity should use LLBL code instead of ADO.NET code.
4- In solutions utilizing the modified CSLA framewrok, you will be using the DeriveEntity subclasses as you business classes. You must implement the follwing modifications for each class:
* make all constructors private
* create an embeded class CRITERIA that preferably inherits CRITERIABASE (see Rocky's lates CSLA Beta 1.5). A standard structure for the Criateria class is for it to have two constructores; one that takes the PK fields of your entity and the other takes a RelationPredicateBucket variable. This would allow the criteria to nicely enacpsolate LLBL's powerful RelationsPredicate bucket to perform any type of filtering
* Write Public Shared service routines that expose the basic CRUD operations (I modified this so that I could write as many service routines as I want and not just basic CRUD). The code in these routines calls the appropiate routine in the DataPorat to perform the required CRUD operation.
* Write a private non-shared routine for each public service routine. This private routine is what will be called by the Server DataPortal (local or remote is decided by the client DataPortal). The code in these private routines is standard LLBL code and not ADO.NET code as in CSLA.
There are some other areas that you have to consider but basically this how things will work. The resulting framework is basically CSLA's dataportal and table security married with LLBL's ORM functionality. As you must have noticed that a good understanding of CSLA's functionality and its plumbing will go along way in allowing you to build your CSLA-LLBL framework. I had fun doing it and I am hoping that FRANS would allow me to post my work for any CSLA veterans willing to integrate the power of LLBL...and beleive me ... its worth it (no more 1500+ store procedures and thats just the top of the iceburg )
OMAR