Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7595669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:43:42+00:00 2026-05-30T21:43:42+00:00

I am using web service which receives a flat DTO representing an Order, and

  • 0

I am using web service which receives a flat DTO representing an Order, and I have to convert my business representation of an order to this flat representation.
Here are the objects-
DTO:
dto

Business object:
business object

now the question is how do I convert my Order entity?
I can think of 2 possible solutions:

  1. Have the Order know how to represent itself as a DTO: OrderDTO dto = order.ToDto();
    But this has the obvious disadvantage of the business entity knowing the data representation.

  2. Have this done by some sort of Convertor: OrderDTO dto = Convertor.Convert(order);.
    But the convertor code would have to look like this:

    if (order is OnlineOrder)
    {
    dto.Email = ((OnlineOrder)order).Email;
    }
    which is, of course, terrible.

Any suggestions? can automapper help here (I’m not really familiar with it)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:43:43+00:00Added an answer on May 30, 2026 at 9:43 pm

    You are looking for a factory, which is essentially what your “Converter” is. Your code would look something like:

    var factory = new OrderDTOFactory();
    OrderDTO orderDTO = factory.CreateOrder(order);
    

    Inside the factory you can impliment it a few different ways. Automapper could be useful here and is something to condsider, though your DTO isn’t very large. Automapper has been most useful to me for objects with many properties that need to be transferred.

    I don’t think your “converter” code is really that terrible. It is easy to read, though not very extensible. However if the amount of subclasses is pretty static, then this isn’t really a problem is it? I am not sure how else you could tell if your class had a specific method or not outside of more granular reflection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a web service which has a couple of methods developed using
I have a xml web service which I would like to track using Google
I have an ASP.net web service that I'm using for a web application which
I'm using a web service which returns a list of products. I created a
I am trying to call a web service (using nusoap ), which work well
I wrote a simple web service in C# using SharpDevelop (which I just got
I am creating an application which involves so many web-service calls. I am using
Using JDeveloper as my IDE, I have a web application which calls services provided
I have an ASP.NET application which talks to a third-party SOAP web service. My
I'm building a web service which receives emails from a number of CRM-systems. Emails

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.