BO generation for CSLA CE & SQL Compact

BO generation for CSLA CE & SQL Compact

Old forum URL: forums.lhotka.net/forums/t/5439.aspx


drozd posted on Monday, September 22, 2008

Hi all,

I'm really new to CSLA in general and I'm trying to check if CSLA CE is a good fit for the project we're soon launching for Windows Mobile/Compact Framework. I wonder if someone here could answer the following questions or just give me some directions of further research.

Do you generate BOs using any generators? Do you have any standard templates for the BOs? How difficult would it be to modify existing full CSLA templates for use with CSLA CE?

I've tried CodeSmith 5.0 with the SQL CE Schema provider, but couldn't connect even to the Northwind.sdf file due to CS trial version restrictions. Any other code generators I could use with existing CSLA templates and Sql CE db?

I'd be grateful for any hints.

Thanks,
Michal

lawrencek replied on Tuesday, September 23, 2008

I am using Code Smith 4.0 ( have not upgraded yet) and the community templates from a while back. 

  CSLA 2.x CodeSmith Templates for C#
  Version: 1.1.0 RC

they get you very close  Just change Csla refs to CslaCE and you are basicly done.

drozd replied on Wednesday, September 24, 2008

Thanks for the tip. I'll give it a try.

drozd replied on Wednesday, September 24, 2008

I've downloaded the templates and they seem to need more work to be used with Sql Compact. Are you using them against a standard Sql Server?

Do you think it makes sense to run CSLA CE completely on the PDA (i.e. against Sql Server Compact) in terms of performance and complexity?

lawrencek replied on Wednesday, September 24, 2008

Yes they are used on SQL 2005 db.  There is an attribute that must be removed from the Primary Key Field.  and you might need to tweak the Factory methods or make the constructor public.

I personally remove the dataportal call and create an instance of my object and then call DataPortal_Fetch methon

something like the following

public static MyObject GetMyObject(int varID)

{

MyObject myObj = new MyObject ();

myObj.DataPortal_Fetch(new Criteria(varID));

return myObj ;

//return DataPortal.Fetch<MyObject >(new Criteria(varID));

}

Doing that keeps the performace up and keeps the Business Object Look and Feel very similar to CSLA.

To me I wanted my business objects to be as close in look and feel to the full framework as possable and there does not seem to be much if any performace penalty involed either.

I think that if you are comfortable with CSLA and like the patterns it uses then it makes sence to follow them to the extent that it is possible in the CF

drozd replied on Thursday, September 25, 2008

Removing the calls to DataPortal was exactly what I was think about - as on CF I would only instantiate BOs locally anyway. Do you modify the BusinessBase class to skip DataPortal calls for Insert/Update as well?

Thanks!

Michal

lawrencek replied on Thursday, September 25, 2008

There is a SaveCE method I use to save objects that bypasses the data.portal

drozd replied on Monday, September 29, 2008

Ok. Thanks for the tip :)

Do you use CodeSmith for generating the SQL / SPs for data access?

Copyright (c) Marimer LLC