Questions tagged [data-access-layer]

Data access layer is a layer of a computer program which provides simplified access to data stored in persistent storage of some kind, such as an entity-relational database.

A data access layer (DAL) in computer software, is a layer of a computer program which provides simplified access to data stored in persistent storage of some kind, such as an entity-relational database.

For example, the DAL might return a reference to an object (in terms of object-oriented programming) complete with its attributes instead of a row of fields from a database table. This allows the client (or user) modules to be created with a higher level of abstraction. This kind of model could be implemented by creating a class of data access methods that directly reference a corresponding set of database stored procedures. Another implementation could potentially retrieve or write records to or from a file system. The DAL hides this complexity of the underlying data store from the external world.

For example, instead of using commands such as insert, delete, and update to access a specific table in a database, a class and a few stored procedures could be created in the database. The procedures would be called from a method inside the class, which would return an object containing the requested values. Or, the insert, delete and update commands could be executed within simple functions like registeruser or loginuser stored within the data access layer.

Also, business logic methods from an application can be mapped to the Data Access Layer. So, for example, instead of making a query into a database to fetch all users from several tables the application can call a single method from a DAL which abstracts those database calls.

1287 questions
14
votes
4 answers

What's the difference between a "Data Service Layer" and a "Data Access Layer"?

I remember reading that one abstracts the low level calls into a data agnostic framework (eg. ExecuteCommand methods etc), and the other usually contains business specific methods (eg. UpdateCustomer). Is this correct? Which is which?
ilitirit
  • 16,016
  • 18
  • 72
  • 111
13
votes
1 answer

Alternatives to the repository pattern?

People have yelled at me, that I should always use the repository pattern, which I've done for quite a while... Now I'm wondering whether there is any decent alternatives for this pattern at all?
ebb
  • 9,297
  • 18
  • 72
  • 123
13
votes
5 answers

Recommended structure for high traffic website

I'm rewriting a big website, that needs very solid architecture, here are my few questions, and pardon me for mixing apples and oranges and probably kiwi too:) I did a lot of research and ended up totally confused. Main question: Which approach…
CodeVirtuoso
  • 6,318
  • 12
  • 46
  • 62
13
votes
3 answers

How to correctly unit test my DAL?

I'm new to unit testing. But how do I unit test my DAL which is written with Entity Framework, so I can make sure my DAL code is working correctly but no database is actually touched? Could someone give as much detail as possible please.
Ray
  • 12,101
  • 27
  • 95
  • 137
13
votes
6 answers

Problem when trying to configure enterprise library 5.0 (Data Access Application Block)

I am running into some problems while trying to get DAAB from Enterprise library 5.0 running. I have followed the steps as per the tutorial, but am getting errors... 1) Download / install enterprise library 2) Add references to the blocks I need…
13
votes
1 answer

Design Patterns for Data Access Layer

I have an application which uses a database (MongoDB) to store information. In the past, I have used a class full of static methods to save and retrieve data but I have since realised this is not very object-oriented or future-proof. Even though it…
user2248702
  • 2,741
  • 7
  • 41
  • 69
13
votes
7 answers

UI, Business Logic Layer, Data Layer and where to put web services

We are developing a web application. We want to possibly reuse the work we do here for a different application that will use the same database, and use the same business rules for reading and writing to said database. Which design would be more…
13
votes
2 answers

PHP Data Access Object

I'm trying to figure out if I'm using the DAO pattern correctly and, more specifically, how abstract db persistence should be by the time it gets to my mapper classes. I'm using PDO as the data-access abstraction object, but sometimes I wonder if…
jerry
  • 2,743
  • 9
  • 41
  • 61
12
votes
3 answers

How should EntityManager be used in a nicely decoupled service layer and data access layer?

Somewhat related to my other question Should raw Hibernate annotated POJO's be returned from the Data Access Layer, or Interfaces instead? , I am experienced in creation of nicely decoupled layers, but not using Hibernate or J2EE/JPA. I have been…
Peter
  • 29,498
  • 21
  • 89
  • 122
12
votes
1 answer

Are there NOSQL data layer design patterns?

I've seen a few ideas on this like instead of like Create, Update, Insert, Delete (CRUD) use Get and Put. That's good. However, I haven't seen much yet on how to deal with complexity. I've been told, "just write a method for every query type that…
sgtz
  • 8,849
  • 9
  • 51
  • 91
12
votes
2 answers

Data access architectures with Raven DB

What data access architectures are available that I can use with Raven DB? Basically, I want to separate persistence via interfaces, so I don't expose underline storage to the upper layers. I.e. I don't want my domain to see IDocumentStore or…
oleksii
  • 35,458
  • 16
  • 93
  • 163
12
votes
4 answers

DDD vs N-Tier (3-Tier) Architecture

I have been practicing DDD for a while now with the 4 distinct layers: Domain, Presentation, Application, and Infrastructure. Recently, I introduced a friend of mine to the DDD concept and he thought it introduced an unnecessary layer of complexity…
12
votes
2 answers

How does the MVC pattern differ, if at all, from the DAL / BLL design pattern?

I'm making my way through the early Data Access Tutorials on Microsoft's ASP.NET website and it occurred to me that this all seems awfully similar to what I have read about separating your logic and presentation code using the MVC pattern. As a…
Martin Doms
  • 8,598
  • 11
  • 43
  • 60
12
votes
1 answer

ASP.NET MVC, EntityFramework, DBContext, Repository in a different Project

I am currently working on an ASP.NET MVC 5 project, and I am trying to polish the architecture of the project; make it as clean and easy for people to work on it in the future as possible. For starters I have moved my EntityFramework models…
teh0wner
  • 1,393
  • 6
  • 16
  • 33
12
votes
3 answers

What does Microsoft recommend for 2nd level Caching in Entity Framework?

I've used "EF Provider Wrappers" made by Jarek Kowalski. It works fine but I noticed "Limitations and Disclaimers" section where it says: The providers have not been extensively tested beyond what’s included in the sample code, so you should use…
Raj
  • 2,642
  • 3
  • 22
  • 20