Click here to Skip to main content
15,898,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends ,

I want to ask which is better to have the BLL in database or in Code ? and why ?

Best Regards
Ab Abulubbad
Posted
Comments
Richard MacCutchan 30-May-12 19:08pm    
What is BLL?
imaa2amha 30-May-12 19:12pm    
its a Business Logic Layer .
Richard MacCutchan 31-May-12 4:42am    
Then please say so; then your question is likely to be understood by more people.

See

BLL

So the BLL should be in code, however some BLL may be in Stored Procedures but called from BLL code. To summarize use both as appropriate.
 
Share this answer
 
It all depends on what is best for your situation. For example, if your logic is very data-specific and will run best in the database, then put it in the database (UDF, stored proc, C#). However, for most business logic, I would recommend putting it in the application.

The one big area I put into SQL is logic that is going to ensure data integrity. For example, if I have an age column, I would make sure it doesn't accept negative numbers.

The business logic that takes processing of the data and/or works with multiple columns usually goes into my application. That keeps the database performant and allows my C# code to do what it does best.
 
Share this answer
 
v2
At a previous job, they had essentially all their business logic in the database as stored procedures. It was terrible. Naming conventions are weird. There were no namespaces. Refactoring is next to impossible. Version control can also be a huge pain.

SQL is code, but it is not a good place to put business logic. Put your business logic in code (C#, VB.NET, whatever), and have some sort of DAL (data access layer). You might consider an ORM (e.g., Entity Framework or NHibernate) and possible build a DAL on top of that. Then on top of that, build your BLL.

If you use LINQ to Entities, it makes communication between your BLL and database easier. However, if you build your DAL correctly, the underlying technology should not change anything as far as the BLL is concerned.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900