/// <summary> /// Translate the json document to a <see cref = "RavenJObject" /> /// </summary> /// <returns></returns> public RavenJObject ToJson() { DataAsJson.EnsureCannotBeChangeAndEnableSnapshotting(); Metadata.EnsureCannotBeChangeAndEnableSnapshotting(); var doc = (RavenJObject)DataAsJson.CreateSnapshot(); var metadata = (RavenJObject)Metadata.CreateSnapshot(); if (LastModified != null) { metadata[Constants.LastModified] = LastModified.Value; metadata[Constants.RavenLastModified] = LastModified.Value.ToString(Default.DateTimeFormatsToWrite, CultureInfo.InvariantCulture); } if (Etag != null) { metadata["@etag"] = Etag.ToString(); } if (NonAuthoritativeInformation != null) { metadata["Non-Authoritative-Information"] = NonAuthoritativeInformation.Value; } //if (metadata.ContainsKey("@id") == false) // metadata["@id"] = Key; doc["@metadata"] = metadata; return(doc); }
/// <summary> /// Translate the json document to a <see cref = "RavenJObject" /> /// </summary> public RavenJObject ToJson(bool checkForId = false) { DataAsJson.EnsureCannotBeChangeAndEnableSnapshotting(); Metadata.EnsureCannotBeChangeAndEnableSnapshotting(); var doc = (RavenJObject)DataAsJson.CreateSnapshot(); var metadata = (RavenJObject)Metadata.CreateSnapshot(); if (LastModified != null) { metadata[Constants.LastModified] = LastModified.Value; metadata[Constants.RavenLastModified] = LastModified.Value.GetDefaultRavenFormat(); } if (Etag != null) { metadata["@etag"] = Etag.ToString(); } if (NonAuthoritativeInformation != null) { metadata["Non-Authoritative-Information"] = NonAuthoritativeInformation.Value; } if (checkForId && metadata.ContainsKey("@id") == false) { metadata["@id"] = Key; } doc["@metadata"] = metadata; return(doc); }
/// <summary> /// Translate the json document to a <see cref = "RavenJObject" /> /// </summary> /// <returns></returns> public RavenJObject ToJson() { DataAsJson.EnsureSnapshot(); Metadata.EnsureSnapshot(); var doc = (RavenJObject)DataAsJson.CreateSnapshot(); var metadata = (RavenJObject)Metadata.CreateSnapshot(); if (LastModified != null) { metadata[Constants.LastModified] = LastModified.Value; } if (Etag != null) { metadata["@etag"] = Etag.Value.ToString(); } if (NonAuthoritativeInformation != null) { metadata["Non-Authoritative-Information"] = NonAuthoritativeInformation.Value; } //if (metadata.ContainsKey("@id") == false) // metadata["@id"] = Key; doc["@metadata"] = metadata; return(doc); }