data-access-layer

Repository Pattern vs DAL

帅比萌擦擦* 提交于 2019-12-17 10:07:34
问题 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? 回答1: 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

Is it possible to stub Entity Framework context and classes to test data access layer?

有些话、适合烂在心里 提交于 2019-12-13 12:15:33
问题 I'm familiar with techniques used for testing controllers and business logic in ASP .NET MVC application. Data access in our app is concentrated in special services which are loosely coupled, use interfaces and work with actual database through Entity Framework. However, as DAL became increasingly more complex, hiding away database implementation details and providing application code with abstractions, we became concerned if we are able to test it by any means. Because it is already tightly

Spring NamedParameterJdbcTemplate not returning result for simple query

£可爱£侵袭症+ 提交于 2019-12-13 07:57:43
问题 Please bare with my limited info on code since having limited access to copy paste complete code. @Repository("BaseDao") public class BaseDaoImpl implements BaseDao{ public NamedParameterJdbcTemplate namedJdbcTemplate; @Autowired public void setDataSource(DataSource dataSource){ this.namedJdbcTemplate = new NamedParameterJdbcTemplate(dataSource); } } @Repository("WelcomeDao") public class WelcomeDaoImpl extends BaseDaoImpl implements WelcomeDao { public List<String> getFunctionTypes() {

Linq To Sql - Making a dynamic search for the Application layer without exposing DAL layer as DLL

 ̄綄美尐妖づ 提交于 2019-12-13 02:08:38
问题 Linq to SQL, C#. I have 3 layers: DAL,BL,Application. I want to build functions of search in the BL for each table so those functions get as a parameter 'where' expresstion from the Application layer. The advantage in this approach is one function for each table so the client can search in a free and dynamic way insted of givving him 5 (for example) ways; restrict his search. For that I need to give my Application layer a DLL of my DAL layer. Doing that is not a good approach to solve the

Where to catch exceptions

跟風遠走 提交于 2019-12-12 12:28:20
问题 I have a WCF svc separated into a Service Layer, Business Logic Layer and Data Access Layer. When my DAL encounters an exception, should I catch it there or let it bubble back up to the Service Layer? And why? Please disregard any client involvement for this scenario, I am only concerned with logging the exceptions on the WCF svc. 回答1: It depends also on how you are architecting your solution. For instance, if the DAL and BLL layers are meant to be totally independent components, then they

How to manage SqlDataReaders in a data access layer?

安稳与你 提交于 2019-12-12 09:15:00
问题 I am trying to get a better handle on decoupling my code, code reuse, etc. I'm tired of typing the below every time I want to read some rows: using(SqlConnection conn = new SqlConnection(myConnString)) { using(SqlCommand cmd = new SqlCommand(cmdTxt, conn)) { conn.Open(); using(SqlDataReader rdr = cmd.ExecuteReader()) { while(rdr.Read()) { /* do something with rows */ } } } } I understand there is LINQ to SQL (I don't like it), and the Entity Framework (still a baby). I have no problems having

Type or Namespace Error

吃可爱长大的小学妹 提交于 2019-12-12 00:16:08
问题 I have two references in my application. In the BAL code i am able to use the namespace "using TestDAL;" But I am not being able to use the namespace of BAL in my .cs page. This is the error i get, CS0246: The type or namespace name 'TestBAL' could not be found (are you missing a using directive or an assembly reference?) And one thing in my bin folder too I only have the TestDAL.dll file. How do I insert TestBAL.dll file? Can anyone help me with what can be possible reason? Thanks in Advance

How the Application layer will be able to dynamicly query the DB in the DAL layer?

北城余情 提交于 2019-12-11 19:08:49
问题 C#, LINQ to SQL Some advice me to open new topic insteed that topic becouse there is no solution for my problem. Now I will need your help to re-design my layers. Linq To Sql - Making a dynamic search for the Application layer without exposing DAL layer as DLL My project consist of 3 layers: DAL, BL, Application. The Linq2Sql is exsist in the DAL layer and he auto-generate a class to each table in the data base, and a ContextObject to manage the data base. I cant change anything in this

Definition of a Data Access Layer in .NET 3.5

旧城冷巷雨未停 提交于 2019-12-11 17:26:04
问题 I have the following code that was written by someone else in my web project: StringBuilder sql = new StringBuilder(""); // Define sql sql.Append("SELECT title "); sql.Append("FROM MyTable "); sql.Append(string.Format("WHERE id = {0} AND Var = '{1}'", myId, myVar)); DataTable dtGroups = SqlHelper.GetDataTable(sql.ToString()); if (dtGroups.Rows.Count > 0) { foreach (DataRow dr in dtGroups.Rows) { return dr["title"].ToString(); } } return ""; I then have a helper class called SqlHelper.cs which

Layered Design /Architecture

老子叫甜甜 提交于 2019-12-11 14:49:11
问题 we use html 5/angular SPA with Webapi at the service which communicates with DAL for dataaccess operations Layer flow would be: presentation(html5/angular controllers/service) --> web api --> DAL - -> DB. we do not have BLL project as such. we are thinking to make DAL as combination of BLL + DAL. And we use DTO objects created through t4 templates and they are used for transfer of data between client and web api and DAL (we dont use EF, we use ADO.Net as underlying provider) should we require