Seperating BAL and DAL, CSLA.Net framework 4

Seperating BAL and DAL, CSLA.Net framework 4

Old forum URL:

Arjun posted on Sunday, October 28, 2012


I have recently started using I really like the way the CSLA enforcing the best practices of class - object concepts. Thanks for such a nice framework.

And my question is on the architecture of application using CSLA.NET 4.

I saw some exising code in CSLA framework, where i have observed both Business layer(factory methods) and data access layer (Dataportal_Insert(), DataPortal_Delete()...etc) in the same class. I want to seperate the BAL and DAL, like all business layer related code in one class library project and the Data access layer related code in another project. Can we do this in CSLA ? if so, Please let me know the best practice to seperate and pros and cons, if any.





JonnyBee replied on Sunday, October 28, 2012

Yes, you can.

Use the ObjectFactory pattern to separate  BAL and DAL into separate assemblies.
This is my preferred coding style.

You can look at the SimpleNtier sample.

I often use a MEF container for IoC and buildup of DataAccess classes simply because it's sufficient for my needs and a standard component in .NET.






  public class Order : BusinessBase<Order>




  public class OrderFactory : ObjectFactory, IOrderFactory



When you use a MEFObjectFactoryLoader (available on

Arjun replied on Monday, October 29, 2012

Thank you very much for your suggestion, will start digging throgh the suggested concepts.



RockfordLhotka replied on Sunday, October 28, 2012

The 'Using CSLA 4: Data Access' book from covers this topic in substantial detail.

Information is also on the FAQ:

Copyright (c) Marimer LLC