dto

Should business objects be able to create their own DTOs?

雨燕双飞 提交于 2019-12-01 06:04:17
Suppose I have the following class: class Camera { public Camera( double exposure, double brightness, double contrast, RegionOfInterest regionOfInterest) { this.exposure = exposure; this.brightness = brightness; this.contrast = contrast; this.regionOfInterest = regionOfInterest; } public void ConfigureAcquisitionFifo(IAcquisitionFifo acquisitionFifo) { // do stuff to the acquisition FIFO } readonly double exposure; readonly double brightness; readonly double contrast; readonly RegionOfInterest regionOfInterest; } ... and a DTO to transport the camera info across a service boundary (WCF), say,

Weaving in toString() implementation with AspectJ

蓝咒 提交于 2019-12-01 03:32:20
Trying to weave in a default toString() method for a large number of DTOs, using compile-time weaving only. The goal is to return a JSON representation using the Jackson library. Followed the suggestions in this article , turned it into annotation-style aspect config, and ended up with the following code: public @Aspect class JsonToStringAspect { private interface JsonToString { public String toString(); } public static class JsonToStringImpl implements JsonToString { public String toString() { return SingletonJsonEncoder.toJsonString(this); } } @SuppressWarnings("unused") @DeclareParents

To use or not to use Data transfer objects(DTO) in a Web Api Chat Application Backend Server

爱⌒轻易说出口 提交于 2019-12-01 03:14:57
I have a chat application backend built using Web Api where I am exposing several database entities directly to clients. I was wondering whether there is any positive points to map the entities to DTOs or should I continue exposing the entities as I am currently. Just to clarify I am not asking a DTO vs non-DTO general question but just advantages of using it in this scenario since most of the fields in the entities would probably be used by the client. Yes, you can expose your entities if this is a small application developed by one person and you only have few days to finish it. If you

Use of DTO in 3 tier architecture [closed]

ぃ、小莉子 提交于 2019-12-01 03:07:27
I am using simple 3 tier architecture. In this I am using DTO classes to communicate between UI,BL and DL. So there is any better way for communication between layers? or this is the right way? DTO, Data transfer Object, is the concept for distribution layer, you use when transferring data between your consumers and your service. So, if you don't publish any service, get off DTO. To answer your question, it also depends on how complex your application is. If it's simple, just use CRUD operation, or you can even use DataTable , DataSet for communication. Otherwise, Domain Entity from DDD is the

Weaving in toString() implementation with AspectJ

心不动则不痛 提交于 2019-12-01 00:10:57
问题 Trying to weave in a default toString() method for a large number of DTOs, using compile-time weaving only. The goal is to return a JSON representation using the Jackson library. Followed the suggestions in this article, turned it into annotation-style aspect config, and ended up with the following code: public @Aspect class JsonToStringAspect { private interface JsonToString { public String toString(); } public static class JsonToStringImpl implements JsonToString { public String toString()

Use of DTO in 3 tier architecture [closed]

会有一股神秘感。 提交于 2019-11-30 23:08:43
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I am using simple 3 tier architecture. In this I am using DTO classes to communicate between UI,BL and DL. So there is any better way for communication between layers? or this is the right way? 回答1: DTO, Data

Is this a proper use of DTO?

此生再无相见时 提交于 2019-11-30 20:59:52
I'm writing a console application that does a good amount of data retrieval from stored procedure recordsets. For each recordset type I'm working with, I have a Repository that uses EF with custom complex types to retrieve the data: public interface IBalanceSheetRepository { IEnumerable<BalanceSheetRecordDTO> GetBalanceSheetRecords(); } public class BalanceSheetRepository : IBalanceSheetRepository { DBContext _context; ... public IEnumerable<BalanceSheetRecordDTO> GetBalanceSheetRecords() { ObjectResult<BalanceSheetRecord> results = _context.GetBalanceSheet(); return results.Select

Is this a proper use of DTO?

百般思念 提交于 2019-11-30 17:20:30
问题 I'm writing a console application that does a good amount of data retrieval from stored procedure recordsets. For each recordset type I'm working with, I have a Repository that uses EF with custom complex types to retrieve the data: public interface IBalanceSheetRepository { IEnumerable<BalanceSheetRecordDTO> GetBalanceSheetRecords(); } public class BalanceSheetRepository : IBalanceSheetRepository { DBContext _context; ... public IEnumerable<BalanceSheetRecordDTO> GetBalanceSheetRecords() {

Optimistic locking in a RESTful application

杀马特。学长 韩版系。学妹 提交于 2019-11-30 14:30:31
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 is converted to a DTO. 5) Corresponding entity is loaded from Hibernate and the DTO's props are copied

Confusion between DTOs (linq2sql) and Class objects!

泄露秘密 提交于 2019-11-30 14:10:42
i have been successfully working with linq2sql and the linq DTOs (the classes that are created by linq2sql) .... I am confused, i have the task of updating an old application and i can see that my DTOs will be used how they should be .... to transport date I am using the repository pattern so i am passing data from the repository to the service via the linq2sql dtos... once i am in the service layer (this is basically my business logic) then I need to pass around class objects .. these class objects are basicaly a mirror image (more or less) of the dtos - there are some changes in some place