dto

How do you map a Dto to an existing object instance with nested objects using AutoMapper?

喜欢而已 提交于 2019-12-17 10:50:12
问题 I have the following Dto and entity with a nested sub entity. public class Dto { public string Property { get; set; } public string SubProperty { get; set; } } public class Entity { public string Property { get; set; } public SubEntity Sub { get; set; } } public class SubEntity { public string SubProperty { get; set; } } How can I set up a mapping with AutoMapper that will allow me to update an existing instance of Entity with the values from a Dto . I'm using Mapper.Map(dto, entity) to

java分层架构概念

拜拜、爱过 提交于 2019-12-16 16:33:56
service是业务层 DAO (Data Access Object) 数据访问 1.JAVA中Action层, Service层 ,modle层 和 Dao层的功能区分?(下面所描述的service层就是biz) 首先这是现在最基本的分层方式,结合了SSH架构。modle层就是对应的数据库表的实体类。 Dao层是使用了Hibernate连接数据库、操作数据库(增删改查)。 以上的Hibernate,Struts,都需要注入到Spring的配置文件中,Spring把这些联系起来,成为一个整体。 其他答案:   action 是业务层的一部分,是一个管理器 (总开关)(作用是取掉转)(取出前台界面的数据,调用biz方法,转发到下一个action或者页面) 模型成(model)一般是实体对象(把现实的的事物变成java中的对象)作用是一暂时存储数据方便持久化(存入数据库或者写入文件)而是 作为一个包裹封装一些数据来在不同的层以及各种java对象中使用 dao是数据访问层 就是用来访问数据库实现数据的持久化(把内存中的数据永久保存到硬盘中 其他答案: Action是一个控制器 Dao主要做数据库的交互工作 Modle 是模型 存放你的实体类 Biz 做相应的业务逻辑处理 2.java中dao层和biz层的区别是什么?   呵呵,这个问题我曾经也有过,记得以前刚学编程的时候

A viewmodel has a behavior/methods compared to a DTO but

这一生的挚爱 提交于 2019-12-14 03:13:31
问题 People on SO often say:"A ViewModel holds methods that can be executed by the view, properties to indicate how toggle view elements, etc. ..." When my ViewModel is sent as a WebApi response to the client serialized to JSON , how can this ViewModel execute a method on the client? This is not clear at all to me. 回答1: You can understand viewmodel in at least two ways instead of passing your business objects to the view (for example MVC Razor view) you pass stripped down objects that contain

Solved-Maybe? How to return list of DTO with nested lists of related DTO

假装没事ソ 提交于 2019-12-14 02:35:34
问题 Without using Automapper, I'm trying to map a list of DTO's into each element of a list of DTO's. Specfically in this example, I want the API to return a list of parents where each parent contains it's list of children and list of pets. I have an EF Core project with the models below (which use fully defined relationships) and exist within a larger database. There is a Parent object, which has many Pet objects and many Child objects, like so: EF Core Models public class Parent { public int

How to populate one extra property in a .Select - LINQ [duplicate]

不想你离开。 提交于 2019-12-13 20:21:42
问题 This question already exists : How to solve Npgsql.NpgsqlOperationInProgressException: A command is already in progress Closed 2 months ago . I'm using my Map method to create DTO object from my context class Company and it looks like this: private CompDTO Map(Company company) { return new CompDTO() { Id = company.Id, Title = company.Title, ParentCompanyId = company.ParentCompanyId, }; } CompDTO looks like this: public class CompDTO { public long Id { get; set; } public string Title { get;

谈架构设计中DDD思想的运用

此生再无相见时 提交于 2019-12-13 18:51:50
首先,描述一下我的业务场景及项目分层结构,非标准DDD(其实我不觉得有标准),只是思考的时候有带入DDD思想。 业务场景: 这是一个ERP系统对中台提供的接口项目,仓储操作大多都是存储过程去完成的。 项目结构,如图: WebAPI层: 这个不用多说了,入口。 DTO层: 增加数据传入传出对象,和领域model、实体model区分。(要不要围绕领域model或从现有系统中提取领域model看实际业务情况,拿我目前这个项目来说,得不偿失。) Services层: 业务服务层(可以命名成BizServices区分),主要写一些业务逻辑,然后调用领域服务层DomainServices(如果有的话),如果没有,则直接调用仓储服务,进行持久化操作。 Repository层 : 打算用dapper进行持久化操作,对外提供RepositoryService。我这里比较特殊,下面讲。 融合了一部分DDD思想后,项目结构和流程本来应该是这样 : Request→WebAPI→DTO→BizServices→DomainServices→RepositoryService→DTO→Response。 一个Request对应一个BizServices可能对应多个DomainServices可能对应多个RepositoryService 实际是这样的 : Request→WebAPI→DTO

How to use optional attributes in web service update messages (DTOs)?

余生颓废 提交于 2019-12-13 15:33:15
问题 BACKGROUND Assume you have a (SOAP) web service, BookService , managing books in a library. In the information model assume that the Book entity has the following attributes: id author publisher title shelfId In order to manipulate the data four web service operations are defined: AddBook GetBook UpdateBook DeleteBook Request and response message are defined for each operation. However, the design of the update message XML schemas is more complicated. We would like to achieve the following

Can ServiceStack operation naming convention be overriden?

送分小仙女□ 提交于 2019-12-13 14:42:21
问题 I need to define a DTO class for a ServiceStack service. Service stack uses convention based on class names, so if my class is called Transmission, the corresponding service will use expose metadata with a type "Transmission" used in HTTP operations. But I already have Transmission class - the one my DTO object will be mapped to. To avoid confusion I want to define TransmissionRequest DTO (probably something better than just "Request" suffix) but keep "Transmission" in exposed service

Converting DTOs to View Models

自古美人都是妖i 提交于 2019-12-13 13:14:46
问题 Does anyone know of a good (read: quick to code) method for converting DTOs to View Models or mapping DTO members to View Model members? Lately I've been finding myself writing many conversion and helper methods but this is a very arduous and tedious task. Moreover, it will often needs to be done twice (DTO -> View Model, View Model -> DTO). Is there a methodology, technique, or technology which would allow me to do this more quickly and efficiently? 回答1: Have a look at Automapper. It is an

Validating data in the service layer against DTOs, Entity Models, or something else?

落花浮王杯 提交于 2019-12-13 12:37:32
问题 I'm working on an ASP.NET MVC project. In the project I have a service layer that accepts DTOs for CRUD operations. When I need to validate business logic, should the validator accept DTOs, Entity Models, or something else entirely? For example: public class ProductService: IProductService { public ValidationResult CreateProduct(ProductDTO productDto) { //call productValidator.Validate(productDto) on the DTO here? Product productEntityModel = mapper.Map<Product>(productDto); //or, call