CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • Seperating BAL and DAL, CSLA.Net framework 4

    rated by 0 users
    Answered (Not Verified) This post has 0 verified answers | 3 Replies | 2 Followers

    Top 500 Contributor
    25 Posts
    Arjun posted on Sun, Oct 28 2012 4:57 AM

    Hi,

    I have recently started using CSLA.net. 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.

     

    Thanks,

    Arjun

     

    All Replies

    Top 10 Contributor
    2,279 Posts
    Suggested by JonnyBee

    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.

    Pros:

    • Your BAL code will look the same no matter what UI style or DataAccess style your app uses
    • You get a clear separation of BAL and DataAccess
    • You may declare interfaces for you dal classes

    Cons:

    • You must handle BO state yourself (MarkOld/MarkNew/MarkClean)
    • You cannot use the ChildDataportal helper methods (UpdateChildren/UpdateChild)

    Sample:

      [Serializable]

      [Csla.Server.ObjectFactory(typeof(IOrderFactory))]

      public class Order : BusinessBase<Order>

     

     

      [Export(typeof(IOrderFactory))]

      public class OrderFactory : ObjectFactory, IOrderFactory

      {

     

    When you use a MEFObjectFactoryLoader (available on http://CslaContrib.CodePlex.com)

    Jonny Bekkum, Norway CslaContrib Coordinator

    Top 10 Contributor
    9,475 Posts

    The 'Using CSLA 4: Data Access' book from http://store.lhotka.net covers this topic in substantial detail.

    Information is also on the FAQ: http://www.lhotka.net/cslanet/faq/DataFaq.ashx

    Rocky

    Top 500 Contributor
    25 Posts
    Arjun replied on Mon, Oct 29 2012 1:11 AM

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

    Thanks,

    Arjun

    Page 1 of 1 (4 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems