private static string SerializeEntity(IDbEntity entity) { string json = DbEntityJsonConvert.SerializePrimaryKeys(entity); if (entity.HasChanges) { json = DbEntityJsonConvert.SerializeEntity(entity, entity.DbEntityChanges()); } return(json); }
public void SerializePrimaryKeys_zero_and_non_zero() { MockAssociativeEntity entity = new MockAssociativeEntity() { RelationalEntity1Id = 1, RelationalEntity2Id = 0 }; string json = DbEntityJsonConvert.SerializePrimaryKeys(entity); Assert.AreEqual("{\"$id\":\"" + entity.Guid + "\",\"Guid\":\"" + entity.Guid + "\",\"RelationalEntity1Id\":" + entity.RelationalEntity1Id + "}", json); }