0

I am new to Azure Gremlin and I am trying to insert an item to the database that includes a list using Container.CreateItemAsync with Microsoft.Azure.Cosmo in C#.

Reading around I tried this. First, I have a class.

public class MyItem
{
    [JsonProperty(PropertyName = "id")]
    public string Id { get; set; }

    [JsonProperty(PropertyName = "myList")]
    public List<string> MyList { get; set; }
}

Then I run

MyItem item = new MyItem
{
    Id = "myItemId",
    MyList = new List<string> { "value1", "value2", "value3" }
};

container.CreateItemAsync(item);

This creates a new item in the database but completely ignores the list. I don't want to insert the list as text but rather as a property that holds an actual list.

Does anyone know how to do this?

Thanks.

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
gulu
  • 115
  • 8
  • Can you share an example of how the document looks once inserted? Newtonsoft.Json should be serializing "MyList" as an array of strings. – Matias Quaranta Mar 15 '23 at 17:19
  • @MatiasQuaranta, yes, it looks like this: [ { "id": "myItemId", "label": "NativeVertex", "type": "vertex" } ] It looks like it completely ignores the list – gulu Mar 16 '23 at 14:33

1 Answers1

0

You used to debug getter setter which proper command. Try using collection class

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 27 '23 at 17:09