Skip to content

Extending DAL class in BLL

Stefan D

Asked Aug 24, 2012, 10:01 PM EDT3 answers
Share
LinkedInX
What's the best way to extend a class generated in the DAL in the BLL of an application. All layers are seperate applications and compiled independently. 

What I want to do is add some business logic to the class so that it can be pulled through to the presentation layer. 

I can easily extend it in the DAL but strict programming says it should go in the BLL

Any thoughts?

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Akkiraju Ivaturi
    0
    Yes. Best practices dictate that you should not consume Data Access objects from View layer. You should interact with Business Layer to accomplish any data related tasks whether it is from Database or any other sources like web services. The reason being if there are any code smells the user can easily hack the crucial information. 

    Always make sure that view layer never reference data access project DLL anytime. The blind way of dealing this is go and delete the dll from the bin folder of the web application or website and handle the errors through code in BLL if at all the view layer is referencing the Data Access DLLs.
    0
  • 0
    Thanks for your reply.

    I forgot to add that the class I was extending was just the data structure and no actual methods/functions.

    Basically, I have several bit columns that I want to display as a status message.  I.e. if the cancelled column is true, then this new method returns "Cancelled" or if the invoiced column is true than return "Invoiced". 

    I rather not change the DB schema and can complete this in the DAL but wanted to move it to the BLL for function separation.
    0
  • Akkiraju Ivaturi
    0
    Yes. Your thought to move this simple logic to BLL is greatly recommended. In some of the projects we do nothing in BLL other than if a DAL returns a string value we just return the string value to BLL and BLL will returns the value to the UI. Even the BLL does not do much processes, it is a separate of concerns. So, what you are thinking is 100% correct and go ahead in your project by placing the code in BLL.

    If you have any other questions, please feel free to ask me.
    0