dto

maptruct复制对像

╄→尐↘猪︶ㄣ 提交于 2019-12-07 16:15:38
现在项目中要求用mapstruct 每个接口要有自己的接收参数对象,就是controller层的入参对象,以Req结尾,比如:IndicatorReq 规定service层不能直接用IndicatorReq,要转换为IndicatorDTO service返回结果也是DTO结尾,比如IndicatorResultDTO 在controller层返回不能直接用IndicatorResultDTO,要转换为IndicatorResultResp 所有一般有四个对象:IndicatorReq -> IndicatorDTO、IndicatorResultDTO -> IndicatorResultResp 在controller层转换 1.引入mapstruct依赖 2.下载插件,idea有对应的mapstruct版本,不对应报错 3.代码: controller层 public List<SelectDimensionResp> getEachDimension (IndicatorReq indicatorReq){ //req 转DTO IndicatorDTO indicatorDTO = RegulationTransfer.INSTANCE.toSelectDimensionDTO(indicatoReq); //DTO作为参数传入service层 List

Serializing a List of Interfaces using the DataContractSerializer

北城以北 提交于 2019-12-07 15:38:14
问题 I have a class and there are some nested classes within it. I serialize it and send it to the wcf service using a method with no problems. Here's the class; public class ComputerDTO { [DataMember] public ComputerTypeDTO Type { get; set; } [DataMember] public string ComputerName { get; set; } [DataMember] public MonitorDTO Monitor { get; set; } } Here's the method; public void Check() { Computer c = new Computer(); ISystemInfoOperations cli = GetServiceClient(); Mapper.CreateMap<Monitor,

Doctrine send an entity to DQL's NEW constructor

倖福魔咒の 提交于 2019-12-07 13:35:40
问题 I have a Blog application in Symfony2 with Doctrine, made of three entities Post Comment User one Post can have many Comments one User can have many comments this application has an json API call "/me/comments" I would like it to return [ { 'text': 'great post', ... 10 other field a comment can have ... 'post': { 'id': 3} }, { 'text': 'i dont like it', ... 10 other field a comment can have ... 'post': {'id': 4} }, ] The normal doctrine function returns me all the relation (User, Post) in the

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

家住魔仙堡 提交于 2019-12-07 01:07:51
问题 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

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

為{幸葍}努か 提交于 2019-12-07 00:15:23
问题 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? 回答1: 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

AutoMapper flattening of nested mappings asks for a custom resolver

天涯浪子 提交于 2019-12-06 18:21:43
问题 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; }

Is it possible to use ODataQueryOptions with DTO's?

本秂侑毒 提交于 2019-12-06 16:39:41
ContentType --> EF model ContentTypes --> DTO In my OData controller: public Task<IQueryable<ContentTypes>> Get(ODataQueryOptions<ContentTypes> options) { var result = options.ApplyTo(_repository.Query().Get() .Where(u => u.UserId == userId) .OrderBy(o => o.Description)) .Cast<ContentTypes>(); return result; } I get an error 500 when trying to apply the ODataQueryOptions . Since the class already inherits ODataController do I even need to do the options.ApplyTo(...) ? The solution for this was to ensure the return type is the the DTO's type, and that the ODataQueryOptions are applied to the EF

Should I have different DTOs for Create and Update? (CRUD) [closed]

限于喜欢 提交于 2019-12-06 15:29:46
Closed . This question is opinion-based . It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . Closed 2 years ago . I'm designing a Web API with the usual CRUD operations on a Person entity. The problem is that I don't know how to design the DTOs. The entity is as follows: public class Person { public int Id { get; set; } public string Name { get; set; } public int Age { get; set; } } I have determined that the DTO should have the very same members: public class PersonDto { public int Id

Update of large entity through service

只谈情不闲聊 提交于 2019-12-06 14:14:58
We're building an n-tier system based on WCF (but not Entity Framework) and we've run into a discussion of the best way to implement updates of large entities. We've created DTOs and map data from our domain model into theese when data is sent to the client. The client then makes some changes and sends them back using the same DTO, in our current implementation. Some of our entities might have 80-100 properties, but perhaps the client only makes changes to one or a few of them. It seems inefficient to populate the whole DTO and send it back and then try to figure out on the server side wich

React-请求篇

萝らか妹 提交于 2019-12-06 13:53:56
请求方式: (1)后台API:HttpPost [FromForm] UserRetisterDTO dto 前端请求: {   body:qs.stringify(dto),  headers:{   Accept: 'application/json',   'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',    } } (2)后台API:HttpPost UserRetisterDTO dto 前端请求: {      data: dto,  headers: {   Accept: '*/*',   'Content-Type': 'application/json',   } } 来源: https://www.cnblogs.com/blog-zhaof/p/11987785.html