data-access-layer

Entity Framework - layered design - Where to put connectionstring?

折月煮酒 提交于 2019-11-28 08:42:47
I am using a layered architecture with the Entity Framework as my datalayer with a bunch of repositories on top which contain the Linq-To-Entities queries. The data layer is one project, next to that I have a Services layer and the interface, which is a website. I want my website to be responsible of specifying the connectionstring for my entity model. How do I do this? I am using a singleton method to get to my entity repository, which is located inside the datalayer. Thanks You can copy the connection string created in the App.Config of the DAL assembly into the connectionStrings section of

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

只愿长相守 提交于 2019-11-27 21:33:23
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 looking at documentation and tutorials, and am puzzled about how to use the EntityManger in an elegant way, as it seems it is responsible for both transactions (which I want to do at my service layer) and persistance methods (which I want to keep in the data access layer). Should I create it at the service layer and inject it into the data access

What is the purpose of a Data Access Layer? [closed]

回眸只為那壹抹淺笑 提交于 2019-11-27 20:13:49
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 Access Layer? In two words: Loose Coupling To keep the code you use to pull data from your data store (database, flat files, web services, whatever) separate from business logic and presentation code. This way, if you have to change data stores, you don't end up rewriting the whole thing. These days, various ORM frameworks are kind of blending the DAL with

Improve data access layer select method Pattern

試著忘記壹切 提交于 2019-11-27 19:32:58
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 ... "; DataTable result = new DataTable(); // GetOpenConnection() is a private method in the class: // it manages the connection string and returns an open and ready connection using (SqlConnection cn = GetOpenConnection()) using (SqlCommand cmd = new SqlCommand(sql, cn)) { // could be any number of parameters, each with a different type cmd.Parameters.Add("

BLL, DAL, OBJ and 3 layer architecture

别来无恙 提交于 2019-11-27 18:48:54
问题 My question is about 3 layer architecture. My project is briefly something like the below, however what annoyed me is after I insert a new column inside my database, I have to update those all fields except for the BLL. In the presentation layer, I created an OBJ as well as inside the DAL plus inside the DAL, there is an SQL query. I have to update all those fields manually. If I do it the 'normal' way, I put all those inside the presentation layer and update all in one place. Am I applying

Nullable values in C++

断了今生、忘了曾经 提交于 2019-11-27 14:35:28
I'm creating a database access layer in native C++, and I'm looking at ways to support NULL values. Here is what I have so far: class CNullValue { public: static CNullValue Null() { static CNullValue nv; return nv; } }; template<class T> class CNullableT { public: CNullableT(CNullValue &v) : m_Value(T()), m_IsNull(true) { } CNullableT(T value) : m_Value(value), m_IsNull(false) { } bool IsNull() { return m_IsNull; } T GetValue() { return m_Value; } private: T m_Value; bool m_IsNull; }; This is how I'll have to define functions: void StoredProc(int i, CNullableT<int> j) { ...connect to database

What is the difference between Database Abstraction Layer & Data Access Layer?

本秂侑毒 提交于 2019-11-27 10:00:39
问题 I am actually stuck in 3-tier structure. I surfed the internet and found two terminologies "Database Abstraction Layer" & "Data Access Layer". What are the differences between the two? 回答1: My understanding is that a data access layer does not actually abstract the database, but rather makes database operations and query building easier. For example, data access layers usually have APIs very similar to SQL syntax that still require knowledge of the database's structure in order to write:

Repository Pattern vs DAL

瘦欲@ 提交于 2019-11-27 09:59:07
Are they the same thing? Just finished to watch Rob Connery's Storefront tutorial and they seem to be similar techinques. I mean, when I implement a DAL object I have the GetStuff, Add/Delete etc methods and I always write the interface first so that I can switch db later. Am I confusing things? Kim Major You're definitely not the one who confuses things. :-) I think the answer to the question depends on how much of a purist you want to be. If you want a strict DDD point of view, that will take you down one path. If you look at the repository as a pattern that has helped us standardize the

Should the repository layer return data-transfer-objects (DTO)?

半城伤御伤魂 提交于 2019-11-27 06:55:00
I have a repository layer that is responsible for my data-access, which is called by a service layer. The service layer returns DTOs which are serialized and sent over the wire. More often than not, services do little more than access a repository and return whatever the repository returns. But for that to work, the repository has to return an instance of that DTO. Otherwise, you would first have to map the data layer object that the repository returns to a DTO in the service layer and return that. That just seems wasteful. On top of that, if creation of the DTOs happens in the service layer,

Why is DataTable faster than DataReader

元气小坏坏 提交于 2019-11-27 04:15:17
So we have had a heated debate at work as to which DataAccess route to take: DataTable or DataReader. DISCLAIMER I am on the DataReader side and these results have shaken my world. We ended up writing some benchmarks to test the speed differences. It was generally agreed that a DataReader is faster, but we wanted to see how much faster. The results surprised us. The DataTable was consistently faster than the DataReader. Approaching twice as fast sometimes. So I turn to you, members of SO. Why, when most of the documentation and even Microsoft, state that a DataReader is faster are our test