dto

AutoMapper flattening of nested mappings asks for a custom resolver

有些话、适合烂在心里 提交于 2019-12-04 23:42:28
I'm somewhat new to AutoMapper and wanted to map a POCO-ish object to a perhaps more complex DTO, the latter tries to be a representation of a Google Books API's Volume resource: Book.cs public class Book { public string Isbn10 { get; set; } public string Isbn13 { get; set; } public string Title { get; set; } public string Author { get; set; } public string Publisher { get; set; } public DateTime Publication { get; set; } public int Pages { get; set; } public string Description { get; set; } public bool InStock { get; set; } } BookDto.cs public class BookDto { public string Kind { get; set; }

Optimistic locking in a RESTful application

纵饮孤独 提交于 2019-12-04 22:49:27
问题 At work, we're developing a RESTful application where the data layer will be handled by Hibernate. But we're not sure how to handle updates on entities. We're planning to do the following: 1) client requests an entity by id 2) Hibernate loads the entity, the requested fields (always with the version) are copied to a DTO that is converted to JSON and sent to the client 3) Client manages some fields and sends the entity (with version number) back to the server. 4) Server receives the JSON that

FreeSql v0.11 几个实用功能说明

心不动则不痛 提交于 2019-12-04 20:36:38
FreeSql 开源发布快一年了,立志成为 .Net 平台方便好用的 ORM,仓库地址: https://github.com/2881099/FreeSql 随着不断的迭代更新,越来越稳定,也越来越强大。预计在一周年的时候(2020年1月1日)发布 1.0 正式版本。 金九银十的日子过去了,在这个铜一般的月份里,鄙人做了几个重大功能,希望对使用者开发提供更大的便利。 一、Dto 映射查询 二、IncludeMany 联级加载 三、Where(a => true) 逻辑表达式解析优化 四、SaveManyToMany 联级保存多对多集合属性 五、迁移实体 - 到指定表名 六、MySql 特有功能 On Duplicate Key Update,和 Pgsql upsert 七、ISelect.ToDelete 高级删除 八、全局过滤器 以下的代码,先决定义代码如下 : IFreeSql fsql = new FreeSql.FreeSqlBuilder() .UseConnectionString(FreeSql.DataType.Sqlite, @"Data Source=|DataDirectory|\db1.db;Max Pool Size=10";) .UseAutoSyncStructure(true) //自动同步实体结构到数据库 .Build(); public

Python: Quick and dirty datatypes (DTO)

馋奶兔 提交于 2019-12-04 17:11:37
问题 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

How to effectively use DTO objects (Data Transfer Objects)?

回眸只為那壹抹淺笑 提交于 2019-12-04 15:47:24
What is the best way to implement DTOs? My understanding is that they are one way to transfer data between objects. For example, in an ASP.Net app, you might use a DTO to send data from the code-behind to the business logic layer component. What about other options, like just sending the data as method parameters? (Would this be easiest in asces wher there is less data to send?) What about a static class that just holds data, that can be referenced by other objects (a kind of global asembly data storage class)? (Does this break encapsulation too much?) What about a single generic DTO used for

Should i use builder pattern in DTO?

。_饼干妹妹 提交于 2019-12-04 11:44:36
问题 This might be a pretty subjetive question, but i would to know some more opinions. I've built a Rest API service with Spring MVC, and i implemented the DTO-Domain-Entity pattern. I want to know what do you think about implementing the Builder pattern in DTOs, something like public class UserResponseDTO extends AbstractResponseDTO { private String username; private Boolean enabled; public UserResponseDTO(String username, Boolean enabled) { this.username = username; this.enabled = enabled; }

MapStruct implementation is not working in Spring Boot Web Application

前提是你 提交于 2019-12-04 11:44:26
I am a newbie to Spring Boot and MapStruct Tool. Earlier, A Project(written by other team using these technologies) is not starting up. Then, I had made some changes in Mapper Abstract Class but now mapper object is coming as null on application startup. Mapper Abstract Class: @Mapper(componentModel = "spring") public abstract class UserAndEmployeeMapper { public UserAndEmployeeMapper INSTANCE = Mappers.getMapper( UserAndEmployeeMapper.class ); @Mapping(source = "username", target = "name") @Mapping(source = "ssn", target = "ssn", defaultValue = "xxxxxx" ) @Mapping(target = "salary", constant

QueryDSL projections with @ManyToOne relation

余生长醉 提交于 2019-12-04 10:06:41
I'm using OpenJPA with QueryDSL, I try to avoid manipulating Tuple objects by using the bean projections features of QueryDSL. I have for example these two Entity, with a @ManyToOne relation. @Entity public class Folder { private Long id; private String name; private String path; @ManyToOne @JoinColumn(name = "FK_FILE_ID") private File file; } @Entity public class File { private Long id; private String fileName; } When I'm executing this query : List<Folder> listFolders = query.from(folder) .list(Projections.bean(Folder.class, folder.name, folder.file.fileName)); I have an error saying that

DDD - which layer DTO should be implemented

删除回忆录丶 提交于 2019-12-04 10:01:25
问题 I am learning about DDD so apologies if my question is naive. I think I need to use Local Data Transfer Object in order to display data to the users as a lot of properties are not part of any of Entity / Value Objects. However, I am not sure where this DTO should be implemented - in a Domain Layer or in an Application Service Layer. The DTO implementation seems part of the Domain, but it means that when I create a collection of DTOs in the Service Layer and pass it to a Presentation Layer, I

Entity Framework and DTO

别等时光非礼了梦想. 提交于 2019-12-04 08:30:49
问题 Im planning to use the Entities generated by the EF (POCO) in sending data to the client instead of creating DTOs? Is this a good practice? Basically, my EDMX file is on my DAL layer. So the UI will have direct access on my DAL. Thanks. 回答1: Basically, I don't think it's a good idea to send DAL objects to your interface, so I would use DTOs. To minimize the effort doing so I would take a look at an DTO generator, to generate DTO code which lets you convert from DAL object to DTO and vice