dto

Should a WCF service return an EntityObject or a POCO/DTO class?

隐身守侯 提交于 2019-12-04 05:13:29
I've been looking at a lot of WCF examples using EntityFramework and most of them seem to return some kind of POCO or DTO class to the client. I was wondering why this was since the default EntityObject includes the [DataContract] attributes and implements INotifyPropertyChanged . Is returning a DTO or POCO class better than an EntityObject (or vise versa)? And is there specific instances where it is better to use one return value over another? As a best practice, you should definitely have it return a DTO/POCO class that is explicitly designed as a data contract and has no persistence logic.

How to handle Dtos for objects which implement multiple interfaces?

依然范特西╮ 提交于 2019-12-04 03:48:31
We are using Dtos in our WCF service interface, but have started to come across issues when the Business Object that the Dto represents implements more than a single interface and we want to return the Dtos in those different contexts and to also be able to treat the Dtos polymorphically on the client. For example lets say we have an interface for an IBusinessObject with several properties containing details of the relationships of the object, attributes of the object etc etc. I have several implementations of this one being a LinearBusinessObject which implement IBusinessObject and ILinear .

Python: Quick and dirty datatypes (DTO)

若如初见. 提交于 2019-12-04 00:23:18
Very often, I find myself coding trivial datatypes like class Pruefer: def __init__(self, ident, maxNum=float('inf'), name=""): self.ident = ident self.maxNum = maxNum self.name = name While this is very useful (Clearly I don't want to replace the above with anonymous 3-tuples), it's also very boilerplate. Now for example, when I want to use the class in a dict, I have to add more boilerplate like def __hash__(self): return hash(self.ident, self.maxNum, self.name) I admit that it might be difficult to recognize a general pattern amongst all my boilerplate classes, but nevertheless I'd like to

PO BO VO DTO POJO DAO 概念及其作用

让人想犯罪 __ 提交于 2019-12-04 00:06:27
PO(bean,entity等命名) : persistant object持久对象,数据库表中的记录在java对象中的显示状态 最形象的理解就是一个PO就是数据库中的一条记录。 好处是可以把一条记录作为一个对象处理,可以方便的转为其它对象。 BO(service,manager,business等命名): business object 业务对象 主要作用是把业务逻辑封装为一个对象。这个对象可以包括一个或多个其它的对象。 形象描述为一个对象的形为和动作,当然也有涉及到基它对象的一些形为和动作。比如处理 一个人的业务逻辑,有睡觉,吃饭,工作,上班等等形为还有可能和别人发关系的形为。 这样处理业务逻辑时,我们就可以针对BO去处理。 VO(from也有此写法) : value object值对象 主要体现在视图的对象, 对于一个WEB页面 将整个页面的属性封装成一个对象。然后 用一个VO对象 在控制层与视图层进行传输交换。 DTO (经过处理后的PO,可能增加或者减少PO的属性): Data Transfer Object数据传输对象 主要用于远程调用等需要大量传输对象的地方。 比如我们一张表有100个字段,那么对应的PO就有100个属性。 但是我们界面上只要显示10个字段, 客户端用WEB service来获取数据,没有必要把整个PO对象传递到客户端,

javaweb开发之vo,po,dto等

Deadly 提交于 2019-12-04 00:06:13
PO(persistant object,持久对象) 最形象的理解就是一个PO就是数据库中的一条记录。 好处是可以把一条记录作为一个对象处理,可以方便的转为其它对象。 BO(business object,业务对象) 主要作用是把业务逻辑封装为一个对象。这个对象可以包括一个或多个其它的对象。 比如一个简历,有教育经历、工作经历、社会关系等等。 我们可以把教育经历对应一个PO,工作经历对应一个PO,社会关系对应一个PO。 建立一个对应简历的BO对象处理简历,每个BO包含这些PO。 这样处理业务逻辑时,我们就可以针对BO去处理。 VO (value object, 值对象 ) 主要对应界面显示的数据对象。对于一个WEB页面,或者SWT、SWING的一个界面,用一个VO对象对应整个界面的值。 DTO (Data Transfer Object,数据传输对象) 主要用于远程调用等需要大量传输对象的地方。 比如我们一张表有100个字段,那么对应的PO就有100个属性。 但是我们界面上只要显示10个字段, 客户端用WEB service来获取数据,没有必要把整个PO对象传递到客户端, 这时我们就可以用只有这10个属性的DTO来传递结果到客户端,这样也不会暴露服务端表结构.到达客户端以后,如果用这个对象来对应界面显示,那此时它的身份就转为VO POJO (plain old java

Set Current TimeZone to @JsonFormat timezone value

自古美人都是妖i 提交于 2019-12-03 20:36:46
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy", timezone = "Asia/Kolkata") private Date activationDate; Hi Guys, From the above java code, i want to set timezone value as Current System timezone using below TimeZone.getDefault().getID() - it returns value as "Asia/Kolkata" But if i set this code to json format @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy", timezone = TimeZone.getDefault().getID()) I am getting error like "The value for annotation attribute JsonFormat.timezone must be a constant expression" Pls help me to solve this issue. Thanks in

Has Chrome improperly implemented the dataTransfer object?

大兔子大兔子 提交于 2019-12-03 17:11:39
问题 When I do this in dragstart event: e.dataTransfer.setData('text/plain', 'text'); e.dataTransfer.setData('text/html', 'html'); e.dataTransfer.setData('application/x-bookmark', 'bookmark'); and this in drop event: for (var i = 0; i < e.dataTransfer.types.length; i++) { var type = e.dataTransfer.types[i]; console.log(type + ":" + e.dataTransfer.getData(type)); } I was supposed to have: text/plain:text text/html:html application/x-bookmark:bookmark as what I got in FF, but actually I got: Text

Many-to-many to DTOs using Automapper

匆匆过客 提交于 2019-12-03 16:37:27
If I have a many-to-many relationship defined in EF: public class StudentImage { public int StudentId { get; set; } public int ImageId { get; set; } public int Order { get; set; } public virtual Student Student { get; set; } public virtual Image Image { get; set; } } public class Student { public int Id { get; set; } public string Name { get; set; } public virtual ICollection<StudentImage> Images { get; set; } } public class Image { public int Id { get; set; } public string Filename { get; set; } public virtual ICollection<StudentImage> Students { get; set; } } And the DTO's: public class

Java EE DAO / DTO (Data Transfer Object) Design Patterns

不问归期 提交于 2019-12-03 13:36:51
问题 Currently I am using struts2 Framework for my work's project, and while designing my DAO classes I have a question in my mind to improve on the design patterns. On my search function, I have 3 kinds of search search with one parameter, and the other, search with multiple parameters, search without parameters. My question is, what is the best way to do the DAO method? in my struts2 method, I'm having public String execute() { //assuming these are passed in from JSP if ("searchByAnId".equals

Dotnet Core中使用AutoMapper

[亡魂溺海] 提交于 2019-12-03 11:39:23
官网: http://automapper.org/ 文档: https://automapper.readthedocs.io/en/latest/index.html GitHub: https://github.com/AutoMapper/AutoMapper/blob/master/docs/index.rst 什么是AutoMapper?   AutoMapper是一个对象-对象映射器。 对象-对象映射通过将一种类型的输入对象转换为另一种类型的输出对象来工作。 使AutoMapper变得有趣的是,它提供了一些有趣的约定,以免去搞清楚如何将类型A映射为类型B。只要类型B遵循AutoMapper既定的约定,就需要几乎零配置来映射两个类型。 为什么要使用AutoMapper?   映射代码很无聊。 测试映射代码更加无聊。 AutoMapper提供了简单的类型配置以及简单的映射测试。 真正的问题可能是“为什么使用对象-对象映射?”映射可以在应用程序中的许多地方发生,但主要发生在层之间的边界中,例如UI /域层或服务/域层之间。 一层的关注点通常与另一层的关注点冲突,因此对象-对象映射导致分离的模型,其中每一层的关注点仅会影响该层中的类型。 AutoMapper的使用场景:   AutoMapper是对象到对象的映射工具。在完成映射规则之后