wcf - DataContractSerializer serialzing the same object more than once per request -
I am in the process of writing a WCF application that will be used by a Silverlight application. I have done most design work and now I am implementing, which has made me with this question.
There is something here which exists in my application:
[DataContract] class person [[datamember] personal towel; most recently used towels; [Datamember] a private gym gym; // This person is present at the gym ...} [data contract] class gym [[datamember] private list & lieutenant; Towel & gt; Towels; // All towels are the owner of this gym ...} What I'm doing here: The most recent use in my application is the towel in the list of towels for the person's gym Some will point out that some of my requests will serial a person object.
Is the data retractable laser enough to understand that it should be asked to sort the exact example of an object twice? If so, how does this deal with it?
If this will be about the same example sorting twice, how should I deal with it so that I do not send unnecessary data to the link?
The following code:
This will evaluate:
If you have added the IsReference property to the DataContract feature of towel class like this:
[DataContract (IsReference = true)] Public class towel {// you have to specify it in [database] because you explicitly add the data contract [public domain ID]; Set; }} You will get an output like this:
& lt ;? XML version = "1.0" encoding = "UTF-16"? & Gt; & Lt; Person xmlns: i = "http://www.w3.org/2001/XMLSchema-instance" xmlns = "http://tempuri.org" & gt; & Lt; Jim & gt; & Lt; Towels & gt; & Lt; Towel z: id = "i1" xmlns: z = "http://schemas.microsoft.com/2003/10/Serialization/" & gt; & Lt; Eid & gt; 1 & lt; / Id & gt; & Lt; / Towel & gt; & Lt; Towel z: id = "i2" xmlns: z = "http://schemas.microsoft.com/2003/10/Serialization/" & gt; & Lt; Eid & gt; 2 & lt; / Id & gt; & Lt; / Towel & gt; & Lt; Towel z: id = "i3" xmlns: z = "http://schemas.microsoft.com/2003/10/Serialization/" & gt; & Lt; Eid & gt; 3 & lt; / Id & gt; & Lt; / Towel & gt; & Lt; / Towels & gt; & Lt; / Gym & gt; & Lt; Recently used towels z: ref = "i1" xmlns: z = "http://schemas.microsoft.com/2003/10/Serialization/" /> & Lt; / Person & gt; Hope it helps.
Comments
Post a Comment