data-access-layer

Nullable values in C++

帅比萌擦擦* 提交于 2019-11-26 16:48:52
问题 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

Should I transform Entity (Persistent) objects to DTO objects?

家住魔仙堡 提交于 2019-11-26 15:33:06
My project is layered as follows: - DAL (Entity) --> BLL (DTO) --> ApplicationComponent (ViewModel) . There will be multiple components of application ( ApplicationComponent ) which will access BLL . Components include windows services, web services, web API and MVC controller. I am transforming NHibernate Entity objects to DTO objects while passing them from DAL to BLL . While passing this state to ApplicationComponent , BLL again converts it to ViewModel . This helps me separate the concerns and how data is handled in each layer. I am not in favour of returning NHibernate Entity object to

Separation of business logic and data access in django

久未见 提交于 2019-11-26 13:54:31
I am writing a project in Django and I see that 80% of the code is in the file models.py . This code is confusing and, after a certain time, I cease to understand what is really happening. Here is what bothers me: I find it ugly that my model level (which was supposed to be responsible only for the work with data from a database) is also sending email, walking on API to other services, etc. Also, I find it unacceptable to place business logic in the view, because this way it becomes difficult to control. For example, in my application there are at least three ways to create new instances of

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

為{幸葍}努か 提交于 2019-11-26 12:56:31
问题 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

Why is DataTable faster than DataReader

人盡茶涼 提交于 2019-11-26 11:06:47
问题 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

Is UnitOfWork equals Transaction? Or it is more than that?

为君一笑 提交于 2019-11-26 08:35:54
问题 The internet is full of information about UnitOfWork pattern; even SO is not an exception. I still do not understand something about it. In my understanding UnitOfWork = Transaction in DB . Thats all; nothing more, nothing less. Is this correct? My confusion is due to how it is implemented in different ORM s. NHibernate uses ISession for more than just a Transaction . Dapper leaves everything to you. My question here is about design pattern only without considering any ORM or technology. If

What is the difference between DAO and Repository patterns?

こ雲淡風輕ζ 提交于 2019-11-26 04:02:46
问题 What is the difference between Data Access Objects (DAO) and Repository patterns? I am developing an application using Enterprise Java Beans (EJB3), Hibernate ORM as infrastructure, and Domain-Driven Design (DDD) and Test-Driven Development (TDD) as design techniques. 回答1: DAO is an abstraction of data persistence . Repository is an abstraction of a collection of objects . DAO would be considered closer to the database, often table-centric. Repository would be considered closer to the Domain,

Should I transform Entity (Persistent) objects to DTO objects?

社会主义新天地 提交于 2019-11-26 04:00:51
问题 My project is layered as follows:- DAL (Entity) --> BLL (DTO) --> ApplicationComponent (ViewModel) . There will be multiple components of application ( ApplicationComponent ) which will access BLL . Components include windows services, web services, web API and MVC controller. I am transforming NHibernate Entity objects to DTO objects while passing them from DAL to BLL . While passing this state to ApplicationComponent , BLL again converts it to ViewModel . This helps me separate the concerns

Separation of business logic and data access in django

馋奶兔 提交于 2019-11-26 02:59:17
问题 I am writing a project in Django and I see that 80% of the code is in the file models.py . This code is confusing and, after a certain time, I cease to understand what is really happening. Here is what bothers me: I find it ugly that my model level (which was supposed to be responsible only for the work with data from a database) is also sending email, walking on API to other services, etc. Also, I find it unacceptable to place business logic in the view, because this way it becomes difficult