Say you have a one to one relationship in your entity model. The code generator will decorate it with the following attributes:
[global::System.Xml.Serialization.XmlIgnoreAttribute()]
[global::System.Xml.Serialization.SoapIgnoreAttribute()]
public RelatedObject Relationship { get {...} set {...} }
I want to serialize my parent object together with all its properties for which data has been loaded through an XML web service. Obviously, these related properties do not get serialized because of these attributes.
So for my purposes I just want to remove these "don't serialize me" attributes. I can do a find and replace in the designer code, but any modifications I make in the designer will put these attributes back in.
In my query I'm .Include()ing and explicitly loading only the child objects that I require for serialization. So I will make sure there are no circularities in my query. Some of the child properties are not required, so I won't Include() them, so they won't be serialized.
Else how do I achieve what I want to do? Make a separate call from my application for each child object? Say I'm returning hundreds of parent objects; I'd have to make hundreds of separate calls to get each child too.
How do I permanently get rid of these attributes?
VS 2008 / EF 3.5.
Just don't do it. It's that simple.
You state on your post that you want to serialize the parent of your object, right?
Now let's see what happens when you do something like that...
And it will never get out, without some encouragement.
So those attributes are there for a good reason.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With