I have the EF databaseModel. I serialize my class thet contains field with EF DB Table Type. I try to deserealize and i have the field with null fields.
class Myclass
{
public EFTable table {get;set;}
}
EFTable
- string str;
- int num;
[global::System.Data.Objects.DataClasses.EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)] [global::System.Runtime.Serialization.DataMemberAttribute()] [global::System.CodeDom.Compiler.GeneratedCode("System.Data.Entity.Design.EntityClassGenerator", "4.0.0.0")]
After deserialization EFTable - string str=null - int num=0
why? how fix it without creating temp classes?
public static byte[] Serialize(BaseInspection inspection)
{
using (var file = File.Create(path.ToString()))
{
Serializer.Serialize(file, inspection);
}
return File.ReadAllBytes(path.ToString());
}
static BaseInspection Desirialize(byte[] path)
{
using (Stream stream = new MemoryStream(path))
return Serializer.Deserialize<BaseInspection>(stream);
}