Skip to content

Implicit conversion from byte[] to ReadOnlyMemory<byte> #18252

Answered by ayende
danielmarbach asked this question in Q&A
Discussion options

You must be logged in to vote

You are looking at the code that is running on the database side. And the types you use aren't actually identical to what is compiled. In this case, if you'll look at the index, the output would be something like:

In other words, it elided the actual types.
Note that by default, you need to add a converter to ReadOnlyMemory<byte> to support proper serialization on the client side, otherwise, you'll get:

In order to solve that, you can use:

var serializerConventions = (NewtonsoftJsonSerializationConventions)store.Conventions.Serialization;
serializerConventions.CustomizeJsonSerializer += serializer =>
{
    serializer.Converters.Add(new ByteArrayConverter());
};


store.Initialize();

Wi…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by danielmarbach
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants