data-access-layer

One complex query vs Multiple simple queries

丶灬走出姿态 提交于 2019-11-29 05:34:15
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 have more responsibility. Or simple queries where you will need to go more to database. In this case however each class will be responsible for loading one type of object. The situation I'm in is that loaded objects will be sent to a Flex application (DTO's). The general rule of thumb here is that server roundtrips are expensive (relative to how

In separate data access & business logic layer, can I use Entity framework classes in business layer?

我的未来我决定 提交于 2019-11-28 20:42:25
In separate data access & business logic layer, can I use Entity framework classes in business layer? EDIT: I don't think I will need to swap out the data access layer from my business logic in the future (i.e. will be SQL Server), however I will for the UI layer. Therefore the question is more meant to be are there any major issues with using EF classes for me in the business layer? Seems like there would be less plumbing code. Typically, the "best practice" approach would be something like this: in your Data layer, you have EF entities that get loaded from and stored back to the database in

Do you allow the Web Tier to access the DAL directly?

孤街浪徒 提交于 2019-11-28 17:18:35
I'm interested in perceived "best practice", tempered with a little dose of reality here. In a web application, do you allow your web tier to directly access the DAL, or should it go through a BLL first? I'm talking specifically of scenarios where there's no "business logic" really involved -- such as a simple query : "Fetch all customers with surname of 'Atwood'". Scenarios where there's any kind of logic absolutely are gonna go through the BLL, so lets call that moo . While you could encapsulate this method inside a BLL object, it seems to be somewhat pointless when often the signature will

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

可紊 提交于 2019-11-28 17:02:28
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? Lotus Notes 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: $Users->select('name,email,datejoined')->where('rank > 0')->limit(10); Data abstraction layers are

IEnumerable vs IQueryable for Business Logic or DAL return Types

纵然是瞬间 提交于 2019-11-28 16:24:38
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 IEnumerable<T> vs. IQueryable<T> IEnumerable<T> as return type https://stackoverflow.com/questions/2712253/ienumerable-and-iqueryable Views with business logic vs code WPF IEnumerable<T> vs IQueryable<T> as DataSource IEnumerable<T> VS IList<T> VS IQueryable<T> What interface should my service return? IQueryable, IList, IEnumerable? Should I return IEnumerable<T>

Difference between Data Access Layer and Model in MVC

て烟熏妆下的殇ゞ 提交于 2019-11-28 15:54:07
问题 I have implemented what I thought was a pretty decent representation of MVC in several web applications but since having joined crackoverflow, I'm finding that perhaps my initial definitions were a bit simplistic and thus I'd really like some clarification on the differences between the Data Access Layer and the Model or Domain Layer of a web application. For context, I currently use data access objects that implement the CRUD functions for a single record in the table that the object

How to write unit tests for database calls

南笙酒味 提交于 2019-11-28 15:46:51
I'm near the beginning of a new project and (gasp!) for the first time ever I'm trying to include unit tests in a project of mine. I'm having trouble devising some of the unit tests themselves. I have a few methods which have been easy enough to test (pass in two values and check for an expected output). I've got other parts of the code which are doing more complex things like running queries against the database and I'm not sure how to test them. public DataTable ExecuteQuery(SqlConnection ActiveConnection, string Query, SqlParameterCollection Parameters) { DataTable resultSet = new DataTable

Should I return IEnumerable<T> or IQueryable<T> from my DAL?

橙三吉。 提交于 2019-11-28 15:06:35
问题 I know this could be opinion, but I'm looking for best practices. As I understand, IQueryable<T> implements IEnumerable<T> , so in my DAL, I currently have method signatures like the following: IEnumerable<Product> GetProducts(); IEnumerable<Product> GetProductsByCategory(int cateogoryId); Product GetProduct(int productId); Should I be using IQueryable<T> here? What are the pros and cons of either approach? Note that I am planning on using the Repository pattern so I will have a class like so

Are long-living transactions acceptable?

心已入冬 提交于 2019-11-28 12:22:36
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 "OK" button and commit transaction, or "Cancel" button and rollback it. If we want to open another dialog window with this data, we can use nested transactions. The question is: Is this way of using transactions acceptable or not? I know that there are a lot of different ways to implement such logic, but I'd like to list advantages and

Use BLL functions without reference the DAL in my API

允我心安 提交于 2019-11-28 11:39:01
问题 I have 3 project (C#) API, BLL and DAL. The DAL reference the DAL and the API reference the BLL. In my API I need to use all the CRUD functions but I can't use the function from my BLL because VS said that "The type "blabla" is defined in a assembly that is not referenced. You need to add the reference (DAL)" but I don't want to referenced the DAL in API project. Is there a way to do it without use my DAL project ? 回答1: In my view, what you are trying to achieve is good way to architect the