public void DerivedEntityTypeShouldOnlySerializeChangedProperties() { EntityType entity = new DerivedEntityType { ID = 7, Complex = new ComplexType { Name = "June", Home = new Address("Xiadu", 71) }, StringCollection = new ObservableCollection <string>(new string[] { "first", "second" }), Name = "July", Home = new HomeAddress("Xingang", 17, "Guangzhou") }; DataServiceCollection <DerivedEntityType> collection = new DataServiceCollection <DerivedEntityType>(context, null, TrackingMode.AutoChangeTracking, "EntitySet", null, null); collection.Add((DerivedEntityType)entity); context.Entities.FirstOrDefault().State = EntityStates.Unchanged; entity.ID = 71; entity.Complex.Home.Code = 17; ((DerivedEntityType)entity).Home.City = "Guangzhou"; Assert.AreEqual(EntityStates.Modified, context.Entities.FirstOrDefault().State); ValidateBodyContent(context, "{\"ID\":71,\"Complex\":{\"Name\":\"June\",\"Home\":{\"Code\":17,\"Street\":\"Xiadu\"}},\"Home\":{\"City\":\"Guangzhou\",\"Code\":17,\"Street\":\"Xingang\"}}"); }
public void OnlyChangedDerivedComplexTypePropertiesShouldBeSentOnPost() { DataServiceCollection <DerivedEntityType> collection = new DataServiceCollection <DerivedEntityType>(context, "EntitySet", null, null); DerivedEntityType entity = new DerivedEntityType(); collection.Add(entity); entity.Home = new HomeAddress("Xiadu", 71, "Guangzhou"); Assert.AreEqual(EntityStates.Added, context.Entities.FirstOrDefault().State); ValidateBodyContent(context, "{\"Home\":{\"City\":\"Guangzhou\",\"Code\":71,\"Street\":\"Xiadu\"}}", SaveChangesOptions.PostOnlySetProperties); }
public void OnlyChangedPropertiesInDerivedEntityTypeShouldBeSentOnPost() { EntityType entity = new DerivedEntityType(); DataServiceCollection <DerivedEntityType> collection = new DataServiceCollection <DerivedEntityType>(context, "EntitySet", null, null); collection.Add((DerivedEntityType)entity); entity.ID = 71; entity.Complex = new ComplexType { Name = "June", Home = new Address("Xiadu", 17) }; ((DerivedEntityType)entity).Home = new HomeAddress("Xingang", 17, "Guangzhou"); Assert.AreEqual(EntityStates.Added, context.Entities.FirstOrDefault().State); ValidateBodyContent(context, "{\"ID\":71,\"Complex\":{\"Name\":\"June\",\"Home\":{\"Code\":17,\"Street\":\"Xiadu\"}},\"Home\":{\"City\":\"Guangzhou\",\"Code\":17,\"Street\":\"Xingang\"}}", SaveChangesOptions.PostOnlySetProperties); }