Table of Contents

Class NHibernateProxyJsonConverter

Namespace
Breeze.Persistence.NH
Assembly
Breeze.Persistence.NH.dll

JsonConverter for handling NHibernate proxies.
Only serializes the object if it is initialized, i.e. the proxied object has been loaded.

public class NHibernateProxyJsonConverter : JsonConverter
Inheritance
JsonConverter
NHibernateProxyJsonConverter
Inherited Members
JsonConverter.CanRead
JsonConverter.CanWrite

Methods

CanConvert(Type)

Handles NHibernate proxy types.

public override bool CanConvert(Type objectType)

Parameters

objectType Type

The type being considered.

Returns

bool

True if the type is an INHibernateProxy.

ReadJson(JsonReader, Type, object?, JsonSerializer)

Not supported: proxies are written to the client but never read back from it.

public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)

Parameters

reader JsonReader

The reader positioned at the value.

objectType Type

The target type.

existingValue object

Any value already present.

serializer JsonSerializer

The serializer in use.

Returns

object

Never returns.

Exceptions

NotImplementedException

Always.

WriteJson(JsonWriter, object?, JsonSerializer)

Write a proxied entity, unwrapping the proxy first, and write null for one that was never loaded.

public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)

Parameters

writer JsonWriter

The writer to write to.

value object

The proxy, or the entity behind it.

serializer JsonSerializer

The serializer in use.

Remarks

An entity already written in this payload is written again as a "$ref" pointing at it. That has to be done by hand here, because a converter bypasses the reference handling Json.NET would otherwise apply.

See Also