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
33
votes
5 answers

No context type was found in the assembly

I'm using .NET 4.0, MVC3, and EF5 with code first. My solution is split up into three projects, with the dependencies as indicated: Project.Web -> Project.BLL -> Project.DAL The Project.DAL layer contains my entity framework data context class and…
32
votes
8 answers

Mocking vs. Test DB?

Earlier I asked this question How to correctly unit test my DAL?, one thing left unanswered for me is if to really test my DAL is to have a Test DB, then what is the role of mocking vs. a testing DB? To add on this, another person suggested to "use…
Ray
  • 12,101
  • 27
  • 95
  • 137
30
votes
6 answers

ASP.NET and Entity Framework in Layered Architecture - using Entity Framework for ORM only

I have an ASP.NET application that uses a layered architecture e.g. presentation layer, business logic layer, data access layer. I don't want to the business layer to have to know anything about how the data access layer is implemented and I'm not…
AJM
  • 32,054
  • 48
  • 155
  • 243
30
votes
9 answers

Where do you put SQL Statements in your c# projects?

I will likely be responsible for porting a vb6 application to c#. This application is a windows app that interacts with an access db. The data access is encapsulated in basic business objects. One class for one table basically. The existing vb6…
Steve
  • 2,153
  • 4
  • 22
  • 31
26
votes
6 answers

Does it make sense to use the repository pattern with a document database?

I'm currently experimenting with MongoDB. I'm moving from a NHibernate/SQL mindset, and so initially I implemented a repository pattern for data access. This was all looking fine until I started using nested documents. Now it's starting to seem…
UpTheCreek
  • 31,444
  • 34
  • 152
  • 221
26
votes
1 answer

IEnumerable vs IQueryable for Business Logic or DAL return Types

I know these questions have been asked before, I'll start by listing a few of them (the ones I've read so far): IEnumerable vs IQueryable List, IList, IEnumerable, IQueryable, ICollection, which is most flexible return type? Returning…
Smudge202
  • 4,689
  • 2
  • 26
  • 44
26
votes
2 answers

What is the difference between DAL, DTO and DAO in a 3 tier architecture style including with MVC

Recently I was learning about ORM (Object Relational Mapping) and the 3 tier architecture style (presentation,business and data persistence). If I understand correctly, I can separate the data persistence layer into DTO and DAO layer. I would like…
Bálint Pap
  • 498
  • 2
  • 12
  • 23
26
votes
6 answers

Difference between Repository and Service layer

I looked through some related questions but still I don't see much difference between the a repository and a service layer. So given the example I suppose it should look like this , if not please tell me why? public interface ProductRepository…
April
  • 435
  • 1
  • 5
  • 9
25
votes
10 answers

What is the purpose of a Data Access Layer?

I started a project a long time ago and created a Data Access Layer project in my solution but have never developed anything in it. What is the purpose of a data access layer? Are there any good sources that I could learn more about the Data…
Bryan Roth
  • 10,479
  • 15
  • 47
  • 56
24
votes
2 answers

Extension Methods for Indexers, would they be good?

Extension Methods for Indexers, would they be good ? I was playing around with some code that re-hydrates POCO's. The code iterates around rows returned from a SqlDataReader and and uses reflection to assign properties from column values. Down my…
judek
  • 313
  • 2
  • 8
24
votes
2 answers

Is UnitOfWork equals Transaction? Or it is more than that?

The internet is full of information about UnitOfWork pattern; even SO is not an exception. I still do not understand something about it. In my understanding UnitOfWork = Transaction in DB. Thats all; nothing more, nothing less. Is this correct? My…
Amit Joshi
  • 15,448
  • 21
  • 77
  • 141
24
votes
4 answers

How do I determine if a column is in the primary key of its table? (SQL Server)

I am currently using... select Table_Name, Column_name, data_type, is_Nullable from information_Schema.Columns ...to determine information about columns in a given database for the purposes of generating a DataAccess Layer. From where can I…
Rory Becker
  • 15,551
  • 16
  • 69
  • 94
23
votes
3 answers

One complex query vs Multiple simple queries

What is actually better? Having classes with complex queries responsible to load for instance nested objects? Or classes with simple queries responsible to load simple objects? With complex queries you have to go less to database but the class will…
Lieven Cardoen
  • 25,140
  • 52
  • 153
  • 244
22
votes
3 answers

POCO's, DTO's, DLL's and Anaemic Domain Models

I was looking at the differences between POCO and DTO (It appears that POCO's are dto's with behaviour (methods?))and came across this article by Martin Fowler on the anaemic domain model. Through lack of understanding, I think I have created one…
dan
  • 5,664
  • 8
  • 45
  • 59
20
votes
4 answers

Ways of unit testing data access layer

I have be trying to look for an effective way in unit testing my data access layer in C#. I'm primary a Java developer and have only used C# for about 6 months, in the past i've used a library called DBUnit to test against a known state database. I…
wenic
  • 1,169
  • 2
  • 14
  • 23
1
2
3
85 86