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

  • Home
  • SEARCH
  • 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 8725671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:05:21+00:00 2026-06-13T08:05:21+00:00

I got some services where I return DTOs, now I can reuse the same

  • 0

I got some services where I return DTOs,
now I can reuse the same DTO for different methods.

let’s say I have the following interface:

List<ProductDTO> GetProductsByReseller(int reseller)
List<ProductDTO> GetProductsByManufacturer(int Manufacturer)
List<ProductDTO> GetProductsByCategory(int Category)

using the same DTO for them is absolutely valid I think, as they all have really the same fields.

public class ProductDTO
{
    public int Id { get; set; }
    public string ProductName { get; set; }
    public int Reseller { get; set; }
    public int Manufacturer { get; set; }
    public int Category { get; set; }
}

Now I have some other methods, for example:

List<ProductDTO> GetProductsWithAdminInfoByCategory(int Category)

For this method I have to extend the DTO with some additional fields.

     #region only for admin
     public int KnownDefects { get; set; }
     public DateTime InStockSince { get; set; }   
     #endregion //only for admin

Is it ok to reuse the existing DTO and simply extend it?
Or should I create a new DTO because some fields would never be used from that Method?

What I think: If only 1 or 2 fields are new (never used in the other cases), maybe it’s ok, as I not have to create a duplicate DTO and the tradeof for maintaining 2 DTOs instead of 1 is ok. Probably it would be good if I derive a AdminProductDTO from ProductDTO, but I don’t know if inheritation is valid for DTOs.

Well am I wrong?
What would be a good treshold value (nbr of changes), from when on to create a new DTO?

Update:
If I expose a service in WCF that would expose the ProductDTO, will it have to transmit the KnownDefects and InStockSince properties if they are not set or null?
Or is WCF clever enough and not need to transmit undefined/null properties at all? (In that case I wouldn’t mind to have only one DTO with 2 properties that are not always used.)

Another Update:
Well if I inherit ProductAdminDTO from ProductDTO, can I still call the following service with it(that would only accept a ProductDTO)?

bool SaveProduct(ProductDTO)

Well I guess I could simply try that out myself, will update later 🙂

  • 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-06-13T08:05:22+00:00Added an answer on June 13, 2026 at 8:05 am

    Well it seems you are stuck at classic inheritance Vs Composition problem.

    Think whether ProductionWithAdminInfo “ISA” Product?
    I don’t think it satisfies ISA relationship. An extra admin information is just another property of the product.

    So composition seems good choice here. ProductWithAdminInfoDTO contains ProductDTO and AdminInfoDTo.

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

Sidebar

Related Questions

I have some C# web services that return JSON. The .NET JavaScriptSerializer returns dates
I got some problems here, I can't make my find_by_sql request to render an
I got some problems in Datagrid WPF I have a datagrid, and I want
I'm developing some RESTful services in WCF 4.0. I've got a method as below:
If I have some APIs using SOAP, how do I know if the methods
I've got a rich domain model, where most classes have some behaviour and some
I've got some RESTful services running in a pure WCF context (i.e. ASP.NET compatibility
So then, I've got a number of methods in a a couple of services
got some problems. Built an applet that has to be used step-by-step. After each
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)

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.