Last post Jun 25, 2019 08:39 PM by Mikesdotnetting
Jun 25, 2019 02:09 PM|rkrex|LINK
I was wondering if I am using the IRepository Pattern should I structure my project files where these Repository Interfaces are in a folder. And if I do place them in a folder would i need to use a file path to access them? Also is the Repository pattern
considered the Data Access Layer? Oh, and one more question. I have always been a little confused about what is considered the Business Logic Layer and what Classes or Methods would be a part of this layer. Thanks for any help.
Jun 25, 2019 02:25 PM|Mikesdotnetting|LINK
I tend to place interface classes in the same folder as their implementations, to save messing around with different namespaces.
Repositories tend to sit in a layer between data access (the actual part of the app that communicates with the data store, typically being dependent on ADO.NET) and business logic. Kind of. Entity Framework merges repositories and data access in one layer.
Flow of communication is usually like this:
Controller > Business Logic/Service > Repository/EF > Data Store (and back again). Often business logic classes contains methods that make calls to the repository layer without any additional code, but that is where you would add any logic that relates to
the business rules of the application.
EDIT: "Controller" in this context could be an MVC controller or a Page Controller (e.g. Code Behind in Web forms or PageModel class in Razor Pages)
Jun 25, 2019 03:37 PM|rkrex|LINK
Thanks for your help. I was wondering what if you wanted a method that calculated pay differently based on the type of employee. Where would you put that Class method in the folder structure of your web application? Thanks !!!
Jun 25, 2019 08:39 PM|Mikesdotnetting|LINK
It largely depends on the size and nature of the application and use of the method. If the method might be used by other applications, you could put it in a class library project and create a Nuget package out of it. Otherwise I might just put in a folder,
which might house other random utility methods or be devoted to classes and methods related to pay calculations. There's no right or wrong answer. In fact, it's quite common to put this sort of thing in one place, and then move it somewhere else as the code