Serialization
Loop Reference Handling
Loop Reference Handling can happen when serialize QuerySource or QuerySourceField by Json SerializeObject without setting ignore for JsonSerializerSettings.
Sample code that cause this issue:
varquerySource=newQuerySource{Id=Guid.NewGuid(),Name="Table 1"};varquerySourceField=newQuerySourceField{Id=Guid.NewGuid(),Name="Field 1"};// make loop referencequerySource.QuerySourceFields.Add(querySourceField);querySourceField.QuerySource=querySource;// has no serializer setting => cause errorvarquerySourceJson=JsonConvert.SerializeObject(querySource);
Configure JsonSerializerSettings.Ignore
to ignore loop reference handling case.
varquerySource=newQuerySource{Id=Guid.NewGuid(),Name="Table 1"};varquerySourceField=newQuerySourceField{Id=Guid.NewGuid(),Name="Field 1"};// has serializer settingJsonSerializerSettingsjsonSetting=newJsonSerializerSettings();jsonSetting.ReferenceLoopHandling=ReferenceLoopHandling.Ignore;varquerySourceJson=JsonConvert.SerializeObject(querySource,jsonSetting);