data-access-layer

Enterprise library caching parameters on stored procs?

浪子不回头ぞ 提交于 2019-12-05 20:28:01
I'm trying to standardise some data access code with my colleagues. One of the aforementioned colleagues asserts that the EntLib Data Access Block trys to cache parameters on stored proc calls. I've had a look in reflector and there is some evidence that it could be caching them. But I don't think it does in the following situation. public Dictionary<long, string> GetQueue(int maxItems) { var sq = new SqlDatabase(_connString.ConnectionString); var result = new Dictionary<long, string>(); using (var cmd = (SqlCommand)sq.GetStoredProcCommand("dbo.GetQueue")) { sq.AddInParameter(cmd, "maxItems",

BLL,DAL,BO,inserting data

心已入冬 提交于 2019-12-05 15:40:28
I need your advice. I am trying to develop a 3 layer architecture in ASP.NET that separates BBL,DAL,BOboj. Inside the DAL, I collect the data via _view. What I wonder, should I write another BOboj for every view??I have already has a BOboj class but it doesn't contain all fields. When inserting data, I have to use my BOboj,however, when listing, should I create BOboj_view class or another something ?? inserting data (My colum only contains those values) BOboj { private int _PId; private string _Name; private int _ClassId; } listing data BOboj_view { private int _PId; private string _Name;

Using DTOs and BOs

ε祈祈猫儿з 提交于 2019-12-05 14:22:49
One area of question for me about DTOs/BOs is about when to pass/return the DTOs and when to pass/return the BOs. My gut reaction tells me to always map NHibernate to the DTOs, not BOs, and always pass/return the DTOs. Then whenever I needed to perform business logic, I would convert my DTO into a BO. The way I would do this is that my BO would have a have a constructor that takes a parameter that is the type of my interface (that defines the required fields/properties) that both my DTO and BO implement as the only argument. Then I would be able to create my BO by passing it the DTO in the

How to organize Data Access Layer (DAL) in ASP.NET

只谈情不闲聊 提交于 2019-12-05 12:25:31
I have an ASP.NET Web Forms application developed in C#. I would like to give structure my application by separating the DAL tasks from the code behind. I created a class in App_Code, DBUtilities that takes care of the communication with the database, in order not to have duplicated code all along the application. The class has methods to get datatables, scalar values, etc... and they accept as parameters the connection string name and the query command as string. The problem is that I have still all the queries' commands in my code behind. Many of them are duplicated all around the pages and

Transactions in “dapper-dot-net”

蹲街弑〆低调 提交于 2019-12-05 10:59:31
How do I create a transaction if my DAL is using dapper-dot-net? My c# winform application will be used in network and the data will be saved to a central sql server. My use case requires use of transactions. Can I do this using dapper, or will I need to use something like NHibernate? Also, is there any risk or limitation with this framework if I am using stored procedures? Will I need to change my approach due any possible limitations? I haven't run into any limitations with using sprocs and the risks you have with dapper are the same risks you would have with sprocs Here is a simple example

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

独自空忆成欢 提交于 2019-12-05 07:55:05
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 Object pattern ). But when reading the following definitions of a Repository Pattern , it seems we can still have Repository even if we don't implement Query Object pattern : a) From: Repositories are the single point where we hand off and fetch objects. It is also the boundary where communication with the storage starts and ends. I think above quote

What would you put into the unit test of a repository class (data access layer)?

别等时光非礼了梦想. 提交于 2019-12-05 01:30:18
问题 I'd like to write a unit test for my data access layer to make sure that everything works allright in it. The question is, what kind of things should I put into the tests? The DAL is a static Repository class which hides the underlying layer (Fluent NHibernate) and exposes stuff to the public through an IQueryable . I thought about CRUD (Create/Retrieve/Update/Delete) operations Transactions Is there anything else about a DAL that is worth testing? Thanks in advance for your answers! 回答1:

Business Object DAL design [closed]

早过忘川 提交于 2019-12-05 00:49:05
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 12 months ago . When designing business objects I have tried several different methods of writing the data access layer. Some have worked out better than others but I have always felt there must be a "better" way. I would really just like to see the different ways people have handled the

How to manage SqlDataReaders in a data access layer?

♀尐吖头ヾ 提交于 2019-12-04 19:32:55
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 to type my queries out, I just don't want to have to type the command contruction, row iterator, etc

I'm having problems understanding IQueryable<T>

*爱你&永不变心* 提交于 2019-12-04 17:45:54
问题 So I'm trying to understand IQueryable<T> . A tutorial I'm reading suggests using it but not really sure why. The code simply returns some values using LINQ to SQL. I've done this plenty of times in the past, but not using IQueryable<T> Why use it with my functions that return more than 1 value? Here's my code: public IQueryable<Items> GetItems() { return from item in db.Items where item.IsActive == true orderby item.ItemNumber select item; } 回答1: IQueryable represents the query as an