Im’ not sure if this solution is the correct one, but it seems to work and is pretty easy:
I have this class
public class TestClass { public string TestString; public string TestStringProperty { get; set; } public DateTime TestDate; public List<string> TestStringList; }
That I want so store and retrieve I tried this here and it seems to work fine. I just put the Object I want to store inbto the Property dictionary:
var c = new TestClass() {TestString = "SimpleStringfield", TestDate = DateTime.Today,TestStringProperty = "TestStringPropertyContent",
TestStringList = new List<string>(new string[] { "item1","item2","item3"})};
var manager = Manager.SharedInstance;
var db = manager.GetDatabase("test_database");
if (db == null)
{
System.Diagnostics.Debug.WriteLine("--------------------------Could not open Database");
}
var doc = db.CreateDocument(); var properties = new Dictionary<string,Object>() { {"type","day"}, {"day",c} };
var rev = doc.PutProperties(properties);
var docread = db.GetDocument(doc.Id); JObject testobject = (JObject)docread.GetProperty("day");
var o = testobject.ToObject<TestClass>();
Is this the right way?