xml - Serialize Linq2Sql Object After Dispose -


I am trying to find an easy way to serialize any object so that only immediately Properties and their "Toasting" values ​​are included. In the case of objects coming from any datacontent, I want to be able to ignore properties of property (i.e., if a property is a complex object then do not include that object in order). This is particularly important if the properties are not loaded because it causes an error "objects can not be settled after using the object" ...

I have the following , But when it tries to use the property which was not loaded into the original datacentext call.

  string type string = o. Gettype () Name; Stringbilder xml = new stringbiller (); Xml.AppendFormat ("& lt; {0}> \ r \ n", type string); Foreign currency (property assets in O.petpap). GetProperties ()) {var Properties Value = Asset. Gate value (o, empty); If (property.GetType ()! = Typeof (System.Data.Linq.Binary) and Property.PropertyType.Name! = "EntitySet`1" & Property. GetCustomAttributes (typeof (XmlIgnoreAttribute), true). () == 0) {xml.AppendFormat ("& lt; {0}> gt; {1}  \ r \ n", property name, property); }} Xml.AppendFormat ("& lt; / {0}>", typstring); Return xml.ToString ();    

You can use a stock serializer with appropriate "ignore" attributes, E.g. Uses and properties you do not want to serialized.

If you want to stick with the approach, you can check to not work on any kind of complexity.

You can use this to see if a given type is primitive or not, but there are some passes that are well-covered here:

< / Div>

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -