Using CSLA with mixed Data Sources.

Using CSLA with mixed Data Sources.

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


tarekahf posted on Tuesday, April 10, 2012

This is probably my third year using CSLA .NET with VS 2005 (.NET 2.0).

Until now, I have never used Code Generator and I am using the templates from the download of CSLA .NET that work with VS 2005 and I am updating them manually to match my case.

In many cases, my projects are based on Business Objects that fetches data from Web Services developed in SAP.

So basically, most of our back-end Database are in SAP, and they are accesses via Web Services. In many other cases, we have to mix this with connection to SQL Server and Adabas DB (for Legacy data which is not yet migrated to SAP). In other cases, we have to fetch information from Active Directory and also from Lotus Notes User Directory.

So, you can imagine that in one Business Object, it may have to fetch information from 2 or 3 different Data Sources, and to perform update, we have to update such sources accordingly. But mostly for update, we are writing to a SQL Server.

Until now, I have never used Code Generator, and I am still using the Templates provided by the CSLA.NET 2.0 Download.

- I would like to know what is the best strategy to implement the Business Objects for cases where you have multiple data sources on mixed platforms ?

 - Can I use a Code Generator for my case?

- Which code generator will allow me to generate Objects in VB, and to enable me to custom develop the code needed for Data Access (CRUD) and have multiple different Data Sources in the back-end (SQL Server and Web Services), and allow easy maintenance?

- Or do you think that the best was is to continue the way I am implementing the BO now which is copying the Templates and changing them manually?

Tarek.

JonnyBee replied on Tuesday, April 10, 2012

That is one of the reasons that I prefer the ObjectFactory approach.

My business objects stays clean - no data access code whatsoever - all the Data Access and mapping code is done in the object factory.

To the best of my knowledge - I know of no generator that will combine multiple data sources into CSLA Business objects. The ones I have seen uses one database or a model (and may generate the database based on the model). I may be wrong - so I expect others to jump in with more info.

So if the generator uses a model you could model the Business Objects and rules - possible map the actual fields to one database and than manually add the code for other data sources. CodeComplete may be a good choice here in that it allows you to start with a model and has both C# and VB.NET templates.

If you are constrained to .NET 2.0 I would consider to move to CSLA N2 (actually CSLA 3.7.1 for .Net 2.0).

Copyright (c) Marimer LLC