c# - Json.Net adding $id to EF objects despite setting PreserveReferencesHandling to "None" -
i've looked @ how remove $id during json serialization answers given not seem working me , hope can figure out doing wrong.
here code:
return jsonconvert.serializeobject(target, new jsonserializersettings { nullvaluehandling = nullvaluehandling.include, preservereferenceshandling = preservereferenceshandling.none, contractresolver = new customcontractresolver(), converters = customconverters }); the output still coming out $id's, but, on entity framework objects, design? if so, there way prevent $id's on entity framework objects?
the custom contractresolver setting overrides preservereferenceshandling setting.
in implementation of defaultcontractresolver/icontractresolver, add this;
public override jsoncontract resolvecontract(type type) { var contract = base.resolvecontract(type); contract.isreference = false; return contract; } this behaves preservereferenceshandling.none setting without custom contractresolver.
Comments
Post a Comment