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
7
votes
3 answers

Strategies for replacing legacy data layer with Entity framework and POCO classes

We are using .net C# 4.0, VS 2010, EF 4.1 and legacy code in this project we are working on. I'm working on a win form project where I have made a decision to start using entity framework 4.1 for accessing an ms sql db. The code base is quite old…
OKB
  • 715
  • 3
  • 14
  • 30
7
votes
3 answers

How to query column names dynamically using Postgres/NpgSQL

I have a filter object to query a table with many columns, and rather than write a condition covering all columns (allowing for optional filtering) like this: WHERE ((:value0 IS NULL) OR (column_name0 = :value0)) AND ((:value1 IS NULL) OR…
Mr Shoubs
  • 14,629
  • 17
  • 68
  • 107
7
votes
3 answers

Repository Add and Create methods

Why are repositories' .Add method usually implemented as accepting the instance of entity to add, with the .Id already "set" (although it can be set again via reflection), which should be repo's responsibility? Wouldn't it be better to implement it…
7
votes
3 answers

Enterprise Library pros and cons

I am developing a complex business application wherein there will be a data access layer. As of now we have two options - either to create our own custom data access layer or to use a Microsoft inbuilt library. I am looking for some basic reasons to…
Mukesh Kumar
  • 166
  • 2
  • 5
  • 13
7
votes
3 answers

Advice on replacing Enterprise Library Data Access Block by Entity Framework

A few year ago, we developed a large ASP.Net application (C# / .net 3.5) that had to be "Database Engine" non-dependent (meaning this application could either use SQL Server, Oracle, MySQL ... as DB engine). For that, we used Enterprise Library Data…
7
votes
2 answers

Autocomplete optimization for large data sets

I am working on a large project where I have to present efficient way for a user to enter data into a form. Three of the fields of that form require a value from a subset of a common data source (SQL Table). I used JQuery and JQuery UI to build an…
7
votes
7 answers

Improve data access layer select method Pattern

Lately I find myself writing data access layer select methods where the code all takes this general form: public static DataTable GetSomeData( ... arguments) { string sql = " ... sql string here: often it's just a stored procedure name ... "; …
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
7
votes
2 answers

Entity Framework conversion from v1 to v4 problem

After converting my data access layer project from EntityFramework v1 to v4 a got a bunch of errors for each of the entity classes: Error 10016: Error resolving item 'EntityTypeShape'. The exception message is: 'Unresolved reference…
Max
  • 19,654
  • 13
  • 84
  • 122
7
votes
1 answer

To Wrap or Not to Wrap: Wrapping Data Access in a Service Facade

For a while now, my team and I have been wrapping our data access layer in a web service facade (using WCF) and calling it from the business logic layer. Meanwhile, we could simply use the repository pattern where the business logic layer consumes…
PureCognition
  • 1,253
  • 2
  • 10
  • 14
7
votes
8 answers

Flat File Database Example

I would like to see some examples of simple flat file databases and how they are accessed through a data layer. I've written to and read from a flat file before, but I have not ever created a data layer that accessed the data for an application…
John Fischer
  • 1,115
  • 3
  • 13
  • 24
7
votes
5 answers

Are long-living transactions acceptable?

I am thinking about using transactions in 2-tier WPF (or windows forms) applications in following way: We can begin new transaction when we open new form for editing data, edit and persist changes transparently in this transaction. Then we can click…
7
votes
5 answers

New .NET 3.5 Project: Which DAL technology to use?

I am preparing a new Windows project and wonder what kind of DAL technology to use. Originally I was looking for something simpler to not spending too much time on building it. But I understand also that it has to be efficient and scalable in the…
Houman
  • 64,245
  • 87
  • 278
  • 460
7
votes
3 answers

Data Access Layer or having object with CRUD methods?

I used to have a Data Access Layer that take the object by parameter and handle with abstraction the type of persistence required. At my new job, the architect is thinking to implement CRUD operation (load..save..delete..update) into all model…
Patrick Desjardins
  • 136,852
  • 88
  • 292
  • 341
7
votes
8 answers

O/R Mappers - Good or bad

I am really torn right now between using O/R mappers or just sticking to traditional data access. For some reason, every time I bring up O/R mappers, fellow developers cringe and speak about performance issues or how they're just bad in general. …
Crios
7
votes
1 answer

Few things about Repository Pattern that I simply don't understand

I've read quite a few topic on what Repository is, but there are still few things bugging me. To my understanding only difference between Repository and traditional data access layers are Repository's query construction capabilities ( ie Query…
user1483278
  • 929
  • 1
  • 9
  • 17