X DevApi - C# strongly typed objects
Posted by: Satish Bodake
Date: October 25, 2022 11:10AM

I'm using MySQL 8.0.28 enabled X DevApi plugin listening on port 33060. I'm looking for Api reference examples that demonstrate on how to store strongly typed objects as a document in a given schema.


public class Payload
public string id { get; set; }
public int JobId { get; set; }
public Dictionary<string, Core> Data { get; set; }

public class Core

public string[] Meta { get; set; }

#### Insert into Doc Store

public async Task InsertDocumentAsync(Payload entity)
if (entity is null)
throw new ArgumentNullException(nameof(entity));


var result = await _dbCollection.Add(entity).ExecuteAsync();
entity.id = result.GeneratedIds[0];
catch (Exception ex)
_logger.LogError("Error inserting into mysql doc store", ex);

It inserts a document successfully with following values -

column - doc value - '{\"_id\": \"00006356dc0a0000000000001908\"}'
column - _id value - BLOB
column - _json_schema value - '{\"type\": \"object\"}'

I could fetched the document but unable to cast result to class type "Payload"

#### fetch doc from store

var d = dbCollection.GetOne(guid);
var doc = Utf8Json.JsonSerializer.Deserialize<Payload>(d.ToString());

Is there any other methods to do above operations? I've been dealing with pretty complex type structure which has multiple complex properties under root type.

Options: ReplyQuote

Written By
X DevApi - C# strongly typed objects
October 25, 2022 11:10AM

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.