Create document with csharp driver


I’m new around here and I’m struggling with the documentation and the C# driver…

How to do a CreateDocument with the C# driver? Assuming I have an object instance named message

client.Query( Create( Collection( "collectionName" ), message ) );

Can you show us the definition of message?

sure. it’s a regular class, which I don’t know how to map to the required Obj expression.

    public sealed class StreamMessage
        public string Id { get; set; }
        public DateTimeOffset Timestamp { get; set; }
        public Dictionary<string, string> Attributes { get; set; }
        public Dictionary<string, string> Annotations { get; set; }
        public string Content { get; set; }

User-defined fields in a document must live under the top-level data field. For example:

    Value result = await client.Query(
                "data", Obj(
                    "name", "Mountainous Thunder",
                    "element", "air",
                    "cost", 15

Your query might work if you do this:

client.Query( Create( Collection( "collectionName" ), Obj( "data", message ) ) );