Deserialization of an xml Entity Framework object have null children

Buiseastegeft

New Member
I have got issues with EF and xml de/serialization.I managed to serialized EF object in xml files but I am stuck with the deserialization of those files.My serialize function : \[code\]public static void SerializeIntoFile(object inputObject, string fileName){ DataContractSerializer serializer = new DataContractSerializer(typeof(Form)); using (XmlWriter wr = XmlWriter.Create(new StringBuilder(fileName))) { serializer.WriteObject(wr, inputObject); }}\[/code\]My deserialize function :\[code\] public static T DeserializeFromStream<T>(Stream stream) { DataContractSerializer dataContract = new DataContractSerializer(typeof(Form)); return (T)dataContract.ReadObject(stream); }\[/code\]This function is call in silverlight with this function :\[code\]private void FilePicker(object sender, System.Windows.RoutedEventArgs e){ var filepicker = new OpenFileDialog(); bool? userClickedOK = filepicker.ShowDialog(); if (userClickedOK == true) { var form = SerialisationHelper.DeserializeFromStream<Form>(filepicker.File.OpenRead()); }}\[/code\]And the input xml file :\[code\]<?xml version="1.0" encoding="utf-8"?><Form xmlns:i="http://www.w3.org/2001/XMLSchema-instance" z:Id="i1" xmlns:z="http://schemas.microsoft.com/2003/10/Serialization/" xmlns="http://schemas.datacontract.org/2004/07/SuiviAT.WebService.EFModel"> <EntityKey xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Data" z:Id="i2" xmlns="http://schemas.datacontract.org/2004/07/System.Data.Objects.DataClasses"> <d2p1:EntityContainerName> SuiviATModelContainer </d2p1:EntityContainerName> <d2p1:EntityKeyValues i:nil="true" /> <d2p1:EntitySetName> FormSet </d2p1:EntitySetName> </EntityKey> <Id> 0 </Id> <Rows> <Row z:Id="i3"> <EntityKey xmlns:d4p1="http://schemas.datacontract.org/2004/07/System.Data" z:Id="i4" xmlns="http://schemas.datacontract.org/2004/07/System.Data.Objects.DataClasses"> <d4p1:EntityContainerName> SuiviATModelContainer </d4p1:EntityContainerName> <d4p1:EntityKeyValues i:nil="true" /> <d4p1:EntitySetName> RowSet </d4p1:EntitySetName> </EntityKey> <Form z:Ref="i1" /> <FormId> 0 </FormId> <FormReference xmlns:d4p1="http://schemas.datacontract.org/2004/07/System.Data.Objects.DataClasses"> <d4p1:EntityKey xmlns:d5p1="http://schemas.datacontract.org/2004/07/System.Data" i:nil="true" /> </FormReference> <Id> 0 </Id> <Label> Couleur </Label> <Type> String </Type> <Value> Bleu </Value> </Row> </Rows></Form>\[/code\]After the deserialization the returned object have is children null and I don't know why ...If someone could help me it would be appreciate !Thanks!
 
Back
Top