Questions tagged [datamember]

204 questions
0
votes
2 answers

How do I override a name in JSON returned by ASP.NET

I have the following code in an ASP.NET Web API 2 app: [DataMember(Name = "override")] public bool? _override; But the JSON I receive has that member named _override, not override. How can I change the naming in the JSON?
David Thielen
  • 28,723
  • 34
  • 119
  • 193
0
votes
1 answer

The DataMember attributes in WCF are not honored when I copy from List to another

When I copy the DataColumns class to the RatesOfPay class, the DataMember attributes in WCF are no longer honored when I use the following code to copy. I want to see results in the order Step8,Step9, Step10 but I get Step10, Step8, Step9 as Order…
Raj
  • 1
0
votes
0 answers

Web Services DataContract object attribute optional

I need to modify an existing method of web services to include additional data member (Like add category attribute to email object). The problem is, the web service method has already been used by a number of applications. This additional attribute…
June
  • 974
  • 5
  • 20
  • 34
0
votes
1 answer

Error when data contract member refer each other

i have a simple data contract which is have a data member that refer to each other, here are the data member: [DataContract(Namespace = "", Name = "ScaleTransactionHeaderMessage")] public class ScaleTransactionHeaderMessage { [DataMember] …
Dimmy Shu
  • 25
  • 4
0
votes
2 answers

Is there a way to decorate multiple properties with DataMember in a data contract in WCF?

I've got a basic WCF service. I've split out my data contracts and one of them is a class with a large amount of public properties. If I want to make these properties available to the client I'm assuming all of these will need to have [DataMember].…
sr28
  • 4,728
  • 5
  • 36
  • 67
0
votes
0 answers

What are the advantages of the DataMember attribute

What is the exact advantages of the DataMember attribute? What is the difference between a serialized Field and a Field with the DataMember attribute. A friend told there is some performance wise gains? EDIT: Consider this example: [Serializable]…
QuantumSec
  • 39
  • 8
0
votes
2 answers

Generic argument property causes error on WebService

Service: Error: The error is with a type that has ChainedListNode. Thing is, when I remove the DataMemberAttribute from Value, the service works. [DataContract] public class ChainedListNode { [DataMember] public T Value { get; set;…
Matheus Simon
  • 668
  • 11
  • 34
0
votes
1 answer

Selective serialization with NetDataContractSerializer

Serializing this class works fine. However, sometimes I'd like to exclude the field. Is this possible? [DataContract] class Foo { [DataMember] Foo _Foo; } Setting the field to null temporarily is impossible.
mafu
  • 31,798
  • 42
  • 154
  • 247
0
votes
2 answers

DataMember property cannot be found on the DataSource in autogenerated code

I know this has been asked before, but I've looked around and I can't find anything that quite matches what my problem is, so apologies for the dupe post. I am writing a .NET #.5 app in C# that uses an internal SqlCE DB. Whenever I run the app in…
pmbasehore
  • 57
  • 1
  • 10
0
votes
2 answers

Creating data members of a class in C#

I am a beginner programmer looking for some help with c#. I am writing a program based on a framework and need to create a data member of a class, then initialize the data member to something. Next,I need to make a property to get and set the data…
user3015999
  • 69
  • 1
  • 3
  • 9
0
votes
3 answers

How to get names of all private data members in a class

I need a function that will return the names of all the private data members in my class as strings (perhaps in an array or list?), where each string is the name of a private, non final data member in my class. The non final condition is optional,…
Josh
  • 1,309
  • 2
  • 17
  • 37
0
votes
3 answers

Better for complex data members to be dynamically or statically allocated?

I am considering a problem and can't come to a conclusive "better" of the two options. It comes down to deciding whether a complex data member (ie, not a primitive) should be a pointer or simply a value. (Note, I have seen many questions about…
tloch14
  • 61
  • 4
0
votes
1 answer

C# DataMember Serializer Ordering Opposite of Expected

According to this article, I'd expect to see the fields in my base class at the top of the list of fields when serializing to JSON. However, I'm seeing the fields at the bottom of the list. The ordering is correct within the actual class itself,…
0
votes
2 answers

How to access names by which data members are declared in c++ and output those names to console

Code: class A { private: int abc; string xyz; } In the above code, how can I access the names by which data members are declared (abc, xyz) and print them to console?
Udit Bhardwaj
  • 1,761
  • 1
  • 19
  • 29
0
votes
0 answers

Serialization by DataContract

What attributes I must used for next class (and/or class members): [DataContract(Namespace = "classNamespace")] public class TestClass { [DataMember(Name = "fieldName1")] public string Field1; [DataMember(Name = "fieldName2")] …