dto

NHibernate - flagging specific properties as 'dirty'

◇◆丶佛笑我妖孽 提交于 2019-12-02 03:49:18
I am working on an NHibernate project and have a question regarding updating transient entities. Basically the workflow is as follows: Create a DTO (projection) and send over the wire to client. This has a small subset of properties from the entity. Client sends back the changed DTO Map the DTO properties back onto the appropriate enitity so an UPDATE statement can be generated and executed by NH. Save the entity Point 4 is where I have the issue. Currently I can achieve this update using the session.Merge() method, however it must first load the entity from the db (assume no 2LC) before

How to convert sqldatareader to list of dto's?

随声附和 提交于 2019-12-01 23:33:49
I just started moving all my ado.net code from the asp.net pages to repo's and created dto's for each table (manually), but now I don't know what is a good efficient way to convert a sqldatareader to a list of my dto objects? For example sake, my dto is Customer. I am using webforms and I am NOT using an ORM. I would like to start slow and work my way up there. Here a short example on how you can retrieve your data using a data reader: var customers = new List<Customer>(); string sql = "SELECT * FROM customers"; using (var cnn = new SqlConnection("Data Source=Your_Server_Name;Initial Catalog

PO/POJO/BO/DTO/VO你能区分开吗?

蹲街弑〆低调 提交于 2019-12-01 12:27:07
PO :persistent object持久对象 1 .有时也被称为Data对象,对应数据库中的entity,可以简单认为一个PO对应数据库中的一条记录。 2 .在hibernate持久化框架中与insert/delet操作密切相关。 3 .PO中不应该包含任何对数据库的操作。 --------------------------------------------------------- POJO :plain ordinary java object 无规则简单java对象 一个中间对象,可以转化为PO、DTO、VO。 1 .POJO持久化之后==〉PO (在运行期,由Hibernate中的cglib动态把POJO转换为PO,PO相对于POJO会增加一些用来管理数据库entity状态的属性和方法。PO对于programmer来说完全透明,由于是运行期生成PO,所以可以支持增量编译,增量调试。) 2 .POJO传输过程中==〉DTO 3 .POJO用作表示层==〉VO PO 和VO都应该属于它。 ---------------------------------------------------------- BO :business object 业务对象 封装业务逻辑为一个对象(可以包括多个PO,通常需要将BO转化成PO,才能进行数据的持久化,反之,从DB中得到的PO

How to add objects of entity class(DTO's value) using “addAttributeMappings” in RestKit?

為{幸葍}努か 提交于 2019-12-01 12:25:47
问题 My json response contains not only strings, but also array of DTO. Object mapping is not happening in the right format. json response body : { "id": null, "componentName": "Home Loan", "dynamicTableDetailDTOList": [ { "id": 1, "fieldName": "username", "fieldType": "string", "isJoin": false, "joinType": null, "joinTable": null, "joinField": null, "displayField": null, "defaultValue": null, "length": 30, "label": "Name", "isrequired": true, "searchable": null, "dynamicTable": null }, { "id": 2,

Should SDO (Service Data Object) be adopted in new project?

此生再无相见时 提交于 2019-12-01 12:08:11
I've been programming in Delphi with Midas/DataSnap for quite long time and quite happy with it. Moving to .NET I'm more than happy with the ADO.NET DataSet. For CRUD application, I'm highly uncomfortable with any kind of ORM. Generic data-structure with automatic diff/delta handling get my job done better for me, an average database application developer. Tried to study Java years ago, and could not find similar idea implemented. The closest I could find is SDO (Service Data Object). I thought it should be widely adopted when I saw it, but I'm wrong. Even the spec is rather old now, I still

What is DTO equivalent term for objects returned from DAL?

孤街醉人 提交于 2019-12-01 11:51:14
I'm already using DTO's for data transfer over a network. Now I'm also introducing different DTO-like classes to the DAL. This is to avoid passing the application (business) objects across layers. To avoid naming confusion, I would like to use another term than DTO but can't find a good one. What is DTO equivalent term for objects returned from DAL? "What's in a name? that which we call a rose by any other name would smell as sweet." - William Shakespeare Also, what Martin Fowler says about POJO: In the talk we were pointing out the many benefits of encoding business logic into regular java

Is there a better way to implment Equals for object with lots of fields?

♀尐吖头ヾ 提交于 2019-12-01 11:04:18
see also Hows to quick check if data transfer two objects have equal properties in C#? I have lot of Data Transfer Objects (DTO) that each contains lots of simple fields . I need to implement Equals on all of them (so I can write some unit tests off transporting them var WCF). The code I am using is: public override bool Equals(object rhs) { RequestArguments other = rhs as RequestArguments; return other != null && other.m_RequestId.Equals(RequestId) && other.m_Type.Equals(m_Type) && other.m_Parameters.Equals(m_Parameters) && other.m_user.Equals(m_user); } There must be a better way!...

Is there a better way to implment Equals for object with lots of fields?

一笑奈何 提交于 2019-12-01 09:38:22
问题 see also Hows to quick check if data transfer two objects have equal properties in C#? I have lot of Data Transfer Objects (DTO) that each contains lots of simple fields . I need to implement Equals on all of them (so I can write some unit tests off transporting them var WCF). The code I am using is: public override bool Equals(object rhs) { RequestArguments other = rhs as RequestArguments; return other != null && other.m_RequestId.Equals(RequestId) && other.m_Type.Equals(m_Type) && other.m

Only update some properties on an EF entity that are not set to null

China☆狼群 提交于 2019-12-01 08:54:29
I've got a browser sending up JSON but it only includes the properties of a given model that have been changed. So once the WCF DataContractJsonSerializer does it's work I have an object that will have perhaps only the ID and Description fields populated. Attaching this to the DbContext as is will result in the description field being updated but all the other fields being set to their types default value in the database. This is because if WCF doesn't see the property specified in the JSON then it'll skip over it, meaning the property in the instance will just use the types default value as

使用dozer将DTO转化为PO

寵の児 提交于 2019-12-01 08:48:16
DTO,就是Data Transfer Object,数据传输对象。 在开发中,经常需要将DTO转化为PO,可以使用dozer。 Maven <dependency> <groupId>net.sf.dozer</groupId> <artifactId>dozer</artifactId> <version>5.5.1</version> </dependency> Utils 工具类BeanMapperUtils 。 import java.util.Collection; import java.util.List; import com.google.common.collect.Lists; import org.dozer.DozerBeanMapper; public class BeanMapperUtils { /** * 持有Dozer单例, 避免重复创建DozerMapper消耗资源. */ private static DozerBeanMapper dozer = new DozerBeanMapper(); /** * 基于Dozer转换对象的类型. */ public static <T> T map(Object source, Class<T> destinationClass) { return dozer.map(source,