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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:59:59+00:00 2026-05-21T03:59:59+00:00

I am having trouble using DataContract s to deserialize where a list wrapper is

  • 0

I am having trouble using DataContracts to deserialize where a list wrapper is augmented with additional data. The important part of the XML is pasted here, with a full link to the XSD and documentation at the end of this post.

<criteria>
  <criterion>
    <name>common-name</name>
    <value>J350</value>
    <matches>3</matches>
  </criterion>
  <criterion>
    <name>designation</name>
    <value>J350</value>
    <matches>8</matches>
  </criterion>
  <matches>2</matches>  <!-- only shows results matching all criteria -->
</criteria>

The point I am at now is:

[CollectionDataContract(Namespace = "TheNamespace")]
public partial class SearchResultsCriteria : List<SearchResultsCriteriaInfo>
{
    [DataMember(Name = "matches", Order = 1)] // fail
    public int Matches { get; set; }
}

[DataContract(Name = "criterion", Namespace = "TheNamespace")]
public partial class SearchResultsCriteriaInfo
{
    [DataMember(Name = "name", Order = 0)]
    public string Name { get; set; }

    [DataMember(Name = "value", Order = 1)]
    public string Value { get; set; }

    [DataMember(Name = "matches", Order = 2)]
    public int Matches { get; set; }

    // all other properties which can show up in the xml
}

Now the problem, when I deserialize this using the DataContractSerializer, I get the list as expected, only all of the values for Matches on SearchResultsCriteria comes through as 0. What am I missing to get the augmented list to deserialize correctly? I found this msdn article which helped me get through some other problems, but doesn’t have anything regarding this specific issue.

EDIT: The order matters!

I came across this other msdn article about the order of the elements in the XML when using DataContract deserialization. So from what I can tell, it looks like the problem is that the order cannot be determined since there is a variable number of <criterion> elements above the criteria matches. I was hoping it would be the case that I could specify the order of the criteria matches to be 1, and when only 1 criteria was specified it would work, because I could live with that situation. However, that does not appear to work when the class is specified with CollectionDataContract as I have specified above.

For more specific context, I am trying to write a service wrapper for the thrustcurve.org api.

  • 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-21T04:00:00+00:00Added an answer on May 21, 2026 at 4:00 am

    I’m not sure what you mean by “augmented list types” exactly, but I will assume you mean list type members that are not classified as DataMember attributes but that nonetheless need to be round-tripped back and forth during the serialization process.

    Based on this understanding, what you need is IExtensibleDataObject. http://msdn.microsoft.com/en-us/library/ms731083.aspx and http://msdn.microsoft.com/en-us/library/ms731138.aspx and http://msdn.microsoft.com/en-us/library/system.runtime.serialization.iextensibledataobject.aspx would be good starting points here.

    If I misunderstood your question…sorry! Please do clarify what you meant.

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

Sidebar

Related Questions

I am having trouble when using List objects: [DataContract] public class Recipe { [DataMember(Name=Allergies)]
I'm having trouble using Short2 for the (x,y) positions in my vertex data. This
Problem I'm having trouble using XdcMake to generate XML documentation in a C++ project
I'm having trouble using the System.Runtime.Serialization.Json.DataContractJsonSerializer class to deserialize DateTime instances contained within a
I'm having trouble using Simple Xml Serializer to build a Message from a complex
Anybody having trouble using AVFoundation with GC ON??? What I am experiencing is that
I am having trouble using the //TODO flag. When I put the //TODO comment
I'm having trouble using jQuery.ajax() to post a gist to Github. The gist is
I am having trouble using the ABPersonViewController with RubyMotion. The error I'm getting is
I'm having trouble using python to write strings into a file: (what I'm trying

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.