c# - Updating Field in RavenDB Document -
good day,
i have ravendb json document in 1 field ("info") contains string looks this:
"{\"value1\":\"9\", \"value2\": \"dog\", ....}"
i remove escaping "\"
characters recognized json list ravendb.
however, have tried updating documents
newstring = oldstring.replace("\\", "")
,
newstring = oldstring.replace(@"\", "")
and newstring = oldstring.trim(new char[] { @"\" })
but not work. after applying these above mentioned methods string looks unchanged.
please see below full code:
while(true) { var result = session.query<documents>() .take(1000).skip(i) .tolist(); if (result.count == 0) break; foreach (var r in result) { string rinfo = r.info.tostring(); rinfo = rinfo.replace("\\", ""); patched_doc r_doc = new patched_doc() { info = rinfo, value = "test", id = r.id, date = r.date, }; session.store(r_doc); session.savechanges(); } session.savechanges(); += result.count; } public class patched_doc { public string info { get; set; } public string value { get; set; } public int id { get; set; } public string date { get; set; } }
thank in advance helping.
you need parse json object , hand on raven db. strings treated strings. use json.net library parse anonymous objects. change info property type of object. assign anonymous object info property.
Comments
Post a Comment