dto

Using a DTO as the model for a view

If you see at the top of an ASP.NET MVC view: <% var dto = (MyDto)Model; %> ...is something wrong? It doesn't feel right to me... ...

Does JAX-RS require data transfer objects (DTO)?

If a method of a JAX-RS application would return a domain object, the representation (say JSON) would contain all attributes of this object - right? But what if this object would contain "private" data, that shouldn't be exposed to the web? And what is about the other direction from outside in: how could be prevented that private fields...

Using DTO Pattern to synchronize two schemas ?

I need to synchronize two databases. Those databases stores same semantic objects but physically different across two databases. I plan to use a DTO Pattern to uniformize object representation : DB ----> DTO ----> MAPPING (Getters / Setters) ----> DTO ----> DB I think it's a better idea than physically synchronize using SQL Query on e...

Mapping Validation Attributes From Domain Entity to DTO

Hi, I have a standard Domain Layer entity: public class Product { public int Id { get; set; } public string Name { get; set; } public decimal Price { get; set;} } which has some kind of validation attributes applied: public class Product { public int Id { get; set; } [NotEmpty, NotShorterThan10Characters, NotL...

DTOs and interfaces

I recently ran across this pattern(?) in our code and wondering how it is useful, if at all. We have a Spring app and a Flex front-end using BlazeDS. It was decided that we use interfaces on our DTOs, like so: Java public interface ISomeDTO { Integer setId(); void getId(Integer i); } public class SomeDTO implements IS...

DTOs : Several DTO (and Assemblers) for the same resource

Hi, I often need, depending on cases, of several DTOs for a same resource. Take the example of photo Albums. Depending of what i want to display, i'll need different data into my DTOs (creation thru a form, list, details, etc.). I will have an albumFormDTO to create an album, an albumDTO collection for a list of albums, and an albumDe...

Is is ever appropriate to put functionality in a DTO?

Is it ever appropriate to put functionality other than basic setters and getters in a DTO? ...

C# Business Object Architecture question regarding Business and DTO objects

Background We have our own Business Object Architecture, a much lighter (...and loosely based on, but does'nt actually use...) version of the "CSLA" business object framework with similar usage, validation, inclusive DAL etc. All code is generated (stored procs and Business Objects are creaed using CodeSmith) The Business Objects are q...

Should I map a DTO to/from a domain entity on both client and server sides?

I've got a rich domain model, where most classes have some behaviour and some properties that are either calculated or expose the properties of member objects (which is to say that the values of these properties are never persisted). My client speaks to the server only via WCF. As such, for each domain entity, I have a corresponding DT...

Can a DTO have instance methods returning derived values?

Is it ever acceptable for a DTO to have instance methods which return derived values based on the DTO's data? Or should DTOs be pure data containers with no additional methods (other than getters/setters)? The purist in me says that it is far to easy for business logic to creep into such methods. However, if (for example) a DTO is sha...

How to handle and organize DTOs for different context ?

When using simple DTOs in various scenarios I have frequently run into the same kind of problem and I always wondered whether there's a better way to deal with it. The thing is, I have a business object, e.g. Asset which has a bunch of properties, child objects and calculated fields, some of them expensive to calculate in sense of time,...

Entity to DTO conversion with JPA

I'm using DataNucleus as a JPA implementation to store my classes in my web application. I use a set of converters which all have toDTO() and fromDTO(). My issue is, that I want to avoid the whole DB being sent over the wire: If I lazy load, the converter will try to access ALL the fields, and load then (resulting in very eager l...

How should I create & map an XML file describing some import data to a DTO?

I have to write a import utility which will import some data held in an xml file. I imagine that I will create a simple DTO object which is the representation of the import data and then write all my code so that it does the import based on this object. The XML file will be the definition of the transfer format, so I expect that 3rd pa...

MVC: Is it considered bad form to give a DTO a reference to the data access layer?

Is it considered bad form to give a DTO a reference to the data access layer? Or should you always pass a DTO between the data access layer and the application layer? EDIT: For example, imagine the following: I keep a product types list in my database. I'd like to render this list in a drop-down box in a partial view. This partial vi...

Should I use DTO over WCF (namedPipes) or not !?

I mean If I was using WCF over http I wouldn't hesitate. My ORM is LLBLGen Pro which provides me with some pretty nice entity collections features, like tracking changes and other. If I would go the DTO path I would lost this functionality. For now there is on the client side a Web app, which does not need any tracking changes funcional...

AutoMapper : Map a many-to-many association into a DTO (Is flattening of collection items supported?)

Hi! I have a many to many association between a Team and an Employee. public class Employee : Entity { public virtual string LastName { get; set; } public virtual string FirstName { get; set; } public virtual string EMail { get; set; } public virtual IList<LoanedItem> LoanedItems { get; private set; } public virtual...

BestPractice: How to display a many-to-many association in a view in a clean way?

Hi! I am using NHibernate and have a many-to-many association between an Employee and a Team. Now I want to display all Employees with the name of its Team member. Possibility 1: using AutoMapper and create a DTO containing the Employee properties and the name of the Team (eager load the Team) display the DTO in the view Possibili...

where should I do the conversion: Domain object<->DTO?

In Domain Layer or Data access layer? ...

Convert XML to Java DTO and back in GWT

Looking for best approach to convert Java DTO to XML and back while using GWT. I saw GWT has XMLParser in its client package which is a DOM Parser. I'm looking for more like a JAXB kind of plugin feature that I can use with GWT. ...

In DDD, how do you work with multiple repositories for read-only lists

What do you do if you need to generate a read-only list of data on a page and that data would naturally come from several, potentially 5 or more different repositories? We're using DDD and have been forcing access to our database through repositories, but there is a scenario that has come up that doesn't seem to fit DDD and we're trying...