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 7061919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:31:55+00:00 2026-05-28T04:31:55+00:00

I have the following DTO definition:- [DataContract] public class AddProductDTO { [DataMember] public string

  • 0

I have the following DTO definition:-

[DataContract]
public class AddProductDTO
{
   [DataMember]
   public string Code { get; set; }
   [DataMember]
   public List<string> Categories { get; set; }
}

and a viewmodel that currently has a constructor as follows :-

public AddProdctViewModel()
{
   Model = new AddProductDTO();
}

the AddProductDTO has been added as a service reference directly in VisualStudio 2010

In my view I have an (Xceed) WPF datagrid in which I would like to be able to enter categories directly. Currently its itemssource is set to Model.Categories. However, this is not working as the Model.Categories value is null.

This raises a few questions I hope I get can some assistance on

  1. In MVVM is it OK to directly reference the WCF DTO class as the model or should I wrap this in something else?
  2. Why is the Model.Categories coming out as null when AddProductDTO is created?*
  3. What is the recommended way of using WPF/WCF/MVVM to populate a list that is part of the DTO?
  • 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-28T04:31:56+00:00Added an answer on May 28, 2026 at 4:31 am

    Personally I prefer to use Model classes for my data objects, and something like AutoMapper to map DTOs to Models. This allows me to keep things like validation (IDataErrorInfo) and property change notifiers (INotifyPropertyChanged) on the Model object, without having to include that data when going to/from WCF

    As for Model.Categories being null, usually I’ll set list objects to a blank list the first time the get method of the property is called to avoid this sort of problem.

    public class ProductModel : INotifyPropertyChanged
    {
        private List<string> _categories;
        public List<string> Categories 
        {
            get
            {
                if (_categories == null)
                    _categories = new List<string>();
    
                return _categories;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following DTO public class Foo { public ServiceStack.Text.JsonObject Bar { get; set;
Assume the following schema class Person{ public int Id {get;set;} public virtual ICollection<Province> Provinces
I am new to XStream I have following DTO @XStreamAlias(outline) public class OutlineItem implements
I have following DTO @XStreamAlias(outline) public class OutlineItem implements java.io.Serializable { private static final
I have the following Dto and entity with a nested sub entity. public class
I have the following domain class: public class Product { public virtual Guid Id
I have the following class: public class Product { public virtual Guid Id {
I have the following classes: abstract class DTO{ } class SubscriptionDTO extends DTO {
I have the following questions concerning code generation for Hibernate annotated DTO/DAO-s: Is it
I have an entity and a corresponding DTO public class PersonEntity { public int

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.