Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Document.Id and Document.Rev properties behaviour #26

Merged
merged 1 commit into from

2 participants

@deadok22

Hi,

I've faced an issue recently, Document["_id"] and Document["_rev"] stay unchanged on Document.Id and Document.Rev update. In my view it is not what you'd normally expect to see.

So, I propose to make Document.Id and Document.Rev properties use JObject's indexer with keys "_id" and "_rev" as backing fields.

@deadok22 deadok22 Changed Document's Rev and Id properties behaviour. They now use JObj…
…ect's

"_rev" and "_id" fields respectively. It helps to avoid getting different
values from properties and using indexer.
0f84ea8
@soitgoes soitgoes merged commit 6cd9af0 into soitgoes:master
@soitgoes
Owner

I like this change. Thanks for the contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 28, 2012
  1. @deadok22

    Changed Document's Rev and Id properties behaviour. They now use JObj…

    deadok22 authored
    …ect's
    
    "_rev" and "_id" fields respectively. It helps to avoid getting different
    values from properties and using indexer.
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 4 deletions.
  1. +17 −4 LoveSeat/Document.cs
View
21 LoveSeat/Document.cs
@@ -73,11 +73,24 @@ public class BulkDocumentResponse
public class Document : JObject, IBaseObject
{
- [JsonProperty("_id")]
- public string Id { get; set; }
+ [JsonIgnore]
+ public string Id
+ {
+ get {
+ JToken id;
+ return this.TryGetValue("_id", out id) ? id.ToString() : null;
+ }
+ set { this["_id"] = value; }
+ }
- [JsonProperty("_rev")]
- public string Rev { get; set; }
+ [JsonIgnore]
+ public string Rev {
+ get {
+ JToken rev;
+ return this.TryGetValue("_rev", out rev) ? rev.ToString() : null;
+ }
+ set { this["_rev"] = value; }
+ }
public string Type { get; private set; }
Something went wrong with that request. Please try again.