protected override Task Write(object value, WriteBuffer buf, LengthCache lengthCache, NpgsqlParameter parameter, bool async, CancellationToken cancellationToken) { var bytes = value as byte[]; if (bytes != null) { if (_byteaHandler == null) { throw new NpgsqlException("Bytea handler was not found during initialization of PostGIS handler"); } return(_byteaHandler.WriteInternal(bytes, buf, lengthCache, parameter, async, cancellationToken)); } return(Write((PostgisGeometry)value, buf, lengthCache, parameter, async, cancellationToken)); }