Jump to content

So I am building a wpf animal shelter management software with entity framework.

Right now I am confused what a business logic layer is and what distinguishes it from the data access layer?

Does my business logic layer use the context to perform CRUD operations on the database?

Where do my view models come in and how does BAL pass things like observable collection to the view models?

How does DAL pass things on to the BAL

stackoverflow/msdn forums and I cannot seem to find the answer?

Gaming Rig: i5-3570k+H100i (4.3 ghz) | P8Z77-i Deluxe | MSI Twin Frozr 7950 Boost | HX650 | 1TB HGST | 840 Evo 250 GB

Link to comment
https://linustechtips.com/topic/281574-n-tier-architecture/
Share on other sites

Link to post
Share on other sites

I dealt with this same problem not too long ago but couldn't come to a satisfying solution at the time. I was working on an ASP.NET application at the time and was trying to have my BAL and DAL contained in the same solution using different projects. The problem that I couldn't find a way around was having my non-DAL projects access data without also needing to reference the entity framework libraries.

 

For example, say a project in your BAL needs information from the database. We'll say it's something in project "B". Say to get that, it can add a reference to a project in your DAL, which we'll call project "D", and use one of it's classes static methods. This method just uses the db context to run a query and return the data. Nothing EF related need be returned to the class in project "B".

 

Since project "D" is accessing the database through the EF it of course needs the EF libraries. But the problem is that because project "B" is calling that method in project "D" that uses the EF, project "B" now also needs a reference to the EF libraries (and it's own config file for it). So I couldn't figure out how to remove the EF dependency on project "B".

 

Since then, I've thought a bit more about the problem. The only option I can think of to fix this and completely separate the layers is to make the DAL it it's own application/service that your application queries remotely. This may be the right way to do it although I didn't try it at the time so I'm not sure if there are any issues with it. I am definitely interested in hearing other peoples answers to your question.

 

One option for passing things between layers is with Data Transfer Objects (DTOs). I'm not sure if it's the best option or not though but it was the best option I found at the time. Still if you choose to use it, the EntitiesToDTOs project can automate their creation for you since you're using the Entity Framework. Or you can implement them yourself.

Link to comment
https://linustechtips.com/topic/281574-n-tier-architecture/#findComment-3824322
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×