public void ISerializationSurrogate() { dbContext.Configuration.ProxyCreationEnabled = false; var serializationContext = new SerializationContexts { ObjectContext = (dbContext as IObjectContextAdapter).ObjectContext, TypeToSerialize = typeof(Product) }; var xmlSerializer = new NetDataContractSerializer(new StreamingContext(StreamingContextStates.All, serializationContext)); var tester = new XmlDataContractSerializerTester<IEnumerable<Order_Detail>>(xmlSerializer, true); var orderDetails = dbContext.Order_Details.ToList(); tester.SerializeAndDeserialize(orderDetails); }
public void SerializationCallbacks() { dbContext.Configuration.ProxyCreationEnabled = false; var serializationContext = new SerializationContexts { ObjectContext = (dbContext as IObjectContextAdapter).ObjectContext, TypeToSerialize = typeof(Category) }; var xmlSerializer = new NetDataContractSerializer(new StreamingContext(StreamingContextStates.All, serializationContext)); var tester = new XmlDataContractSerializerTester<IEnumerable<Category>>(xmlSerializer, true); var categories = dbContext.Categories.ToList(); tester.SerializeAndDeserialize(categories); }