public override IEnumerator <T> GetEnumerator() { return(TransformResults <T>((jr) => { if (_shouldLookupDocById) { var key = Json.ParseValue(jr, "id") as string; var json = client.Get <string>(key); var jsonWithId = addIdToJson(json, key); //_id is omitted from the Json return by Get return JsonConvert.DeserializeObject <T>(jsonWithId); } else { var jObject = Json.ParseValue(jr, "value"); return JsonConvert.DeserializeObject <T>(jObject); } })); }
public static T TransformRow(JsonReader reader, ICouchbaseClient client, bool shouldLookupById) { if (shouldLookupById) { var key = Json.ParseValue(reader, "id") as string; var json = client.Get <string>(key); if (string.IsNullOrEmpty(json)) { return(default(T)); } var jsonWithId = DocHelper.InsertId(json, key); //_id is omitted from the Json return by Get return(JsonConvert.DeserializeObject <T>(jsonWithId)); } else { var jObject = Json.ParseValue(reader, "value"); return(JsonConvert.DeserializeObject <T>(jObject)); } }