dto

AutoMapper - Why it is overwriting whole object? [duplicate]

余生长醉 提交于 2019-12-05 20:32:23
This question already has an answer here: Automapper: Update property values without creating a new object 3 answers I don't understand why it's overwriting my whole object. The reason is that I get my User object from db an I want to assign new values from DTO. Instead of just adding those new values it's creating new object that has new values but all previous are set to null . How can I make sure that in this case he will "upgrade" my object, not create new one? Scenario /users/{id} - PUT // User has id, username, fullname // UserPut has fullname public HttpResponseMessage Put(int id,

Should I implement DTOs in repository pattern with EF?

此生再无相见时 提交于 2019-12-05 20:18:46
问题 In my project I'm using EF Code First approach. I have a repository layer, service layer and presentation layer (ASP.NET MVC). I'm using a dedicated viewmodel for each view. What I'm confused about is that should my services return entities to the controller for mapping them to the viewmodels, or should I implements DTOs and return them from services? So the question is when the flow is like "EF -> Repository -> Service -> UI", what will be the data transformation. "Entity -> DTO -> Viewmodel

abp(net core)+easyui+efcore实现仓储管理系统——ABP WebAPI与EasyUI结合增删改查之二(二十八)

痞子三分冷 提交于 2019-12-05 17:09:47
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统——ABP总体介绍(一) abp(net core)+easyui+efcore实现仓储管理系统——解决方案介绍(二) abp(net core)+easyui+efcore实现仓储管理系统——领域层创建实体(三) abp(net core)+easyui+efcore实现仓储管理系统——定义仓储并实现 (四) abp(net core)+easyui+efcore实现仓储管理系统——创建应用服务(五) abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之控制器(六) abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之列表视图(七) abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之增删改视图(八) abp(net core)+easyui+efcore实现仓储管理系统——展现层实现增删改查之菜单与测试(九) abp(net core)+easyui+efcore实现仓储管理系统——多语言(十) abp(net core)+easyui+efcore实现仓储管理系统——使用 WEBAPI实现CURD (十一)

学习Spring-Data-Jpa(十二)---投影Projections-对查询结果的扩展

随声附和 提交于 2019-12-05 12:14:52
  Spring-Data数据查询方法的返回通常的是Repository管理的聚合根的一个或多个实例。但是,有时候我们只需要返回某些特定的属性,不需要全部返回,或者只返回一些复合型的字段。Spring-Data允许我们对特定的返回类型建模,以便更有选择的检索托管聚合的部分视图。 1、基于接口的投影   查询执行引擎在运行时为返回的每个元素创建该接口的代理实例,并将调用转发到目标对象的公开方法。   1.1、闭合投影(Closed Projections):一个投影接口,其get方法都与实体类的属性相同,被认为是一个闭合投影。如果使用闭合投影Spring-Data可以优化查询执行,因为我们知道支持投影代理所需要的所有属性。   比如说一个Admin类如下: /** * admin实体 * * @author caofanqi */ @Data @Entity @Builder @Table(name = "jpa_admin") @NoArgsConstructor @AllArgsConstructor public class Admin { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String username; private String

Set Current TimeZone to @JsonFormat timezone value

橙三吉。 提交于 2019-12-05 06:52:26
问题 @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

浅析VO、DTO、DO、PO的概念、区别和用处

ぃ、小莉子 提交于 2019-12-05 06:26:42
篇文章主要讨论一下我们经常会用到的一些对象:VO、DTO、DO和PO。 由于不同的项目和开发人员有不同的命名习惯,这里我首先对上述的概念进行一个简单描述,名字只是个标识,我们重点关注其概念: 概念: VO (View Object ): 视图对象,用于展示层,它的作用是把某个指定页面(或组件)的所有数据封装起来。 DTO (Data Transfer Object ): 数据传输对象,这个概念来源于J2EE的设计模式,原来的目的是为了EJB的分布式应用提供粗粒度的数据实体,以减少分布式调用的次数,从而提高分布式调用的性能和降低网络负载,但在这里,我泛指用于展示层与服务层之间的数据传输对象。 DO (Domain Object ): 领域对象,就是从现实世界中抽象出来的有形或无形的业务实体。 PO (Persistent Object ): 持久化对象,它跟持久层(通常是关系型数据库)的数据结构形成一一对应的映射关系,如果持久层是关系型数据库,那么,数据表中的每个字段(或若干个)就对应PO的一个(或若干个)属性。 模型: 下面以一个时序图建立简单模型来描述上述对象在三层架构应用中的位置 用户发出请求(可能是填写表单),表单的数据在展示层被匹配为VO。 展示层把VO转换为服务层对应方法所要求的DTO,传送给服务层。 服务层首先根据DTO的数据构造(或重建)一个DO

JAVA-正则例子记录

此生再无相见时 提交于 2019-12-05 06:19:46
正则表达式在筛选字符串的时候特别有用,但有时候会记不得语法,除了一些常用的匹配,有些自己用到的需要记下来,以便以后查找 PS:Regexper是JS风格的正则,所以JAVA中的\需要\\ 筛选包名 例如: com.test.dto.demo.dto想要替换成:com.test.po.demo.po 表达式: ^*\\.dto$|^*\\.dto(?=\\.)$* 匹配大小写名字 PS: []中匹配一个字符,可以加范围如:A-Za-z0-9 例如 XXXQuery XXXquery XXXQUERY 表达式 ^*[qQ][uU][eE][rR][yY]$ 格式化字符串 对字符串中的空格,回车进行排除 \s*|\t|\r|\n 来源: https://www.cnblogs.com/liangwen/p/11909799.html

What is the best way of using DTOs in a SOA application?

允我心安 提交于 2019-12-05 05:03:36
We are implementing a SOA web application using EF, WCF and jQuery. Here is our architecture in a brief view: ------------- --- | UI | | | ------------- | | | Services | | D | ------------- | T | | Businsess | | O | ------------- | | | Dal | | | ------------- --- We know that we should have DTO classes to pass data between the layers specially between the Services and the UI but We have some conceptual issues about the way of using DTOs (to send to the UI or receive from UI). For Data-Driven project we can use POCO to generate the DTO objects automaticly. But in big applications it's not that

Using a WCF Service with Entity Framework 4 and…DTO?

半世苍凉 提交于 2019-12-05 03:35:44
As described above I'm implementing a multi-tier architecture to work with WCF and Entity Framework 4 (with poco). Since I'm already have persistence ignorance with POCO I do need implement DTO or I can use WCF in its pure way? The main quote is - I do need DTO to pass a lightweight object on the network or I can use my POCO entities. What you guys recommend? Its hard to answer unless you define what the "pure way" is. Are we talking SOA pure or WCF pure? WCF proxies already are DTOs in a way because they do not bring along any business logic across your service contract. Creating another

Many-to-many to DTOs using Automapper

廉价感情. 提交于 2019-12-05 00:01:03
问题 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;