{"id":1709,"date":"2014-12-16T19:05:14","date_gmt":"2014-12-16T19:05:13","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/?p=1709"},"modified":"2014-12-16T19:05:14","modified_gmt":"2014-12-16T19:05:13","slug":"moving-no-schema-stack-c-and-dynamic-types","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/","title":{"rendered":"Moving No Schema up the Stack with C# and Dynamic Types"},"content":{"rendered":"<p>One of the significant benefits of working with Couchbase Server 2.0 is its flexible schema.\u00a0 Documents are stored as JSON, allowing for implicitly structured records that impose no order on each other.\u00a0 In the real world, that &#8220;implicit structure&#8221; comes from your application.\u00a0 When you create a new user in your application, the associated document is a JSON serialized version of your domain object.<\/p>\n<div class=\"geshifilter\">\n<div class=\"javascript geshifilter-javascript\" style=\"font-family:monospace;\"><span style=\"color: #003366; font-weight: bold;\">public<\/span> <span style=\"color: #003366; font-weight: bold;\">class<\/span> User<br \/><span style=\"color: #009900;\">{<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #009900;\">[<\/span>JsonIgnore<span style=\"color: #009900;\">]<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #003366; font-weight: bold;\">public<\/span> string Id <span style=\"color: #009900;\">{<\/span> get<span style=\"color: #339933;\">;<\/span> set<span style=\"color: #339933;\">;<\/span> <span style=\"color: #009900;\">}<\/span><br \/>\u00a0 \u00a0 <br \/>\u00a0 \u00a0 <span style=\"color: #009900;\">[<\/span>JsonProperty<span style=\"color: #009900;\">(<\/span><span style=\"color: #3366CC;\">&#8220;username&#8221;<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #009900;\">]<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #003366; font-weight: bold;\">public<\/span> string Username <span style=\"color: #009900;\">{<\/span> get<span style=\"color: #339933;\">;<\/span> set<span style=\"color: #339933;\">;<\/span> <span style=\"color: #009900;\">}<\/span><br \/>\u00a0 \u00a0 <br \/>\u00a0 \u00a0 <span style=\"color: #009900;\">[<\/span>JsonProperty<span style=\"color: #009900;\">(<\/span><span style=\"color: #3366CC;\">&#8220;password&#8221;<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #009900;\">]<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #003366; font-weight: bold;\">public<\/span> string Password <span style=\"color: #009900;\">{<\/span> get<span style=\"color: #339933;\">;<\/span> set<span style=\"color: #339933;\">;<\/span> <span style=\"color: #009900;\">}<\/span><br \/>\u00a0 \u00a0 <br \/>\u00a0 \u00a0 <span style=\"color: #009900;\">[<\/span>JsonProperty<span style=\"color: #009900;\">(<\/span><span style=\"color: #3366CC;\">&#8220;type&#8221;<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #009900;\">]<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #003366; font-weight: bold;\">public<\/span> string Type <span style=\"color: #009900;\">{<\/span> get <span style=\"color: #009900;\">{<\/span> <span style=\"color: #000066; font-weight: bold;\">return<\/span> <span style=\"color: #3366CC;\">&#8220;user&#8221;<\/span><span style=\"color: #339933;\">;<\/span> <span style=\"color: #009900;\">}<\/span> <span style=\"color: #009900;\">}<\/span><br \/><span style=\"color: #009900;\">}<\/span><\/p>\n<p><span style=\"color: #006600; font-style: italic;\">\/\/stored as { &#8220;username&#8221; : &#8220;hmoody&#8221;, &#8220;password&#8221; : &#8220;b3cca&#8221; }<\/span><\/div>\n<\/div>\n<p>While this approach is common in applications where documents are read into and written from well defined domain objects, there are cases where it the structure of the documents is intentionally less well defined.\u00a0 In such cases, it might not be feasible to have a domain object per document type.\u00a0<\/p>\n<p>While in languages such as Python or Ruby, it might be common to use a less object-oriented approach (e.g., dictionaries or hashes), in strongly typed languages such as C# or Java, it&#39;s far more common to represent application data using strongly typed data objects, often called plain old (Java|C#) objects.\u00a0 However, it is certainly possible to use dynamic language approaches with these languages.\u00a0<\/p>\n<p>When a user asked recently <a href=\"https:\/\/stackoverflow.com\/questions\/14568254\/couchbase-deserialize-json-into-dynamic-type\">on StackOverflow<\/a> how to pull JSON documents out of Couchbase and into loosely typed C# objects, I proposed two options.\u00a0 For the rest of this post, I&#39;ll describe a few basic extension methods you could use to take a similar approach with your data.<\/p>\n<p>The first approach is to store <em>Dictionary<string, object><\/em> instances.\u00a0 Dictionaries naturally map to JSON structures, so they&#39;re a natural choice for working with documents in a less structured way.\u00a0 Nested dictionaries also map well to complex JSON structures.\u00a0<\/p>\n<div class=\"geshifilter\">\n<div class=\"csharp geshifilter-csharp\" style=\"font-family:monospace;\">var user1 <span style=\"color: #008000;\">=<\/span> <a href=\"https:\/\/www.google.com\/search?q=new+msdn.microsoft.com\"><span style=\"color: #008000;\">new<\/span><\/a> Dictionary<span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">string<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">object<\/span><span style=\"color: #008000;\">><\/span><br \/><span style=\"color: #008000;\">{<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #008000;\">{<\/span> <span style=\"color: #666666;\">&#8220;username&#8221;<\/span>, <span style=\"color: #666666;\">&#8220;jzablocki&#8221;<\/span> <span style=\"color: #008000;\">}<\/span>,<br \/>\u00a0 \u00a0 <span style=\"color: #008000;\">{<\/span> <span style=\"color: #666666;\">&#8220;preferences&#8221;<\/span>, <a href=\"https:\/\/www.google.com\/search?q=new+msdn.microsoft.com\"><span style=\"color: #008000;\">new<\/span><\/a> Dictionary<span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">string<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">object<\/span><span style=\"color: #008000;\">><\/span><br \/>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #008000;\">{<\/span><br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #008000;\">{<\/span> <span style=\"color: #666666;\">&#8220;theme&#8221;<\/span>, \u00a0<span style=\"color: #666666;\">&#8220;green&#8221;<\/span><span style=\"color: #008000;\">}<\/span>,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #008000;\">{<\/span> <span style=\"color: #666666;\">&#8220;timezone&#8221;<\/span>, \u00a0<span style=\"color: #666666;\">&#8220;EST&#8221;<\/span> <span style=\"color: #008000;\">}<\/span><br \/>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #008000;\">}<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #008000;\">}<\/span><br \/><span style=\"color: #008000;\">}<\/span><span style=\"color: #008000;\">;<\/span><\/div>\n<\/div>\n<p>To save and read this document, we&#39;ll add extension methods to save and retrieve dictionaries.\u00a0 These methods will live inside a new static class named <em>CouchbaseDynamicExtensions<\/em>.<\/p>\n<div class=\"geshifilter\">\n<div class=\"csharp geshifilter-csharp\" style=\"font-family:monospace;\"><span style=\"color: #0600FF; font-weight: bold;\">public<\/span> <span style=\"color: #0600FF; font-weight: bold;\">static<\/span> <span style=\"color: #6666cc; font-weight: bold;\">class<\/span> CouchbaseDynamicExtensions <span style=\"color: #008000;\">{<\/span> <span style=\"color: #008000;\">&#8230;<\/span> <span style=\"color: #008000;\">}<\/span><\/div>\n<\/div>\n<p>The first method will simply wrap the standard <em>ExecuteStore<\/em> method, but will encapsulate a few things.\u00a0 First, it will take care of serializing the Dictionary to JSON using the Newtonsoft.JSON library.\u00a0 You can modify the serializer settings to support camel casing or other JSON formatting options.\u00a0 I&#39;ve left the defaults in place.\u00a0 Second, I&#39;ve encapsulated the <em>IStoreOperationResponse <\/em>details into an arguably simpler Tuple return.\u00a0 Since tuples are commonly returned in dynamic languages, and I&#39;m trying to be more dynamic, this seemed like an appropriate approach.<\/p>\n<div class=\"geshifilter\">\n<div class=\"csharp geshifilter-csharp\" style=\"font-family:monospace;\"><span style=\"color: #0600FF; font-weight: bold;\">public<\/span> <span style=\"color: #0600FF; font-weight: bold;\">static<\/span> Tuple<span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">bool<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">int<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">string<\/span><span style=\"color: #008000;\">><\/span> StoreDictionary<span style=\"color: #008000;\">(<\/span><span style=\"color: #0600FF; font-weight: bold;\">this<\/span> ICouchbaseClient client, StoreMode storeMode,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #6666cc; font-weight: bold;\">string<\/span> key, Dictionary<span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">string<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">object<\/span><span style=\"color: #008000;\">><\/span> dictionary<span style=\"color: #008000;\">)<\/span><br \/><span style=\"color: #008000;\">{<\/span><br \/>\u00a0 \u00a0 var json <span style=\"color: #008000;\">=<\/span> JsonConvert<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">SerializeObject<\/span><span style=\"color: #008000;\">(<\/span>dictionary<span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/>\u00a0 \u00a0 var result <span style=\"color: #008000;\">=<\/span> client<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">ExecuteStore<\/span><span style=\"color: #008000;\">(<\/span>storeMode, key, json<span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><\/p>\n<p>\u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">if<\/span> <span style=\"color: #008000;\">(<\/span><span style=\"color: #008000;\">!<\/span>result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Success<\/span><span style=\"color: #008000;\">)<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #008000;\">{<\/span><br \/>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">if<\/span> <span style=\"color: #008000;\">(<\/span>result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Exception<\/span> <span style=\"color: #008000;\">!=<\/span> <span style=\"color: #0600FF; font-weight: bold;\">null<\/span><span style=\"color: #008000;\">)<\/span> <span style=\"color: #0600FF; font-weight: bold;\">throw<\/span> result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Exception<\/span><span style=\"color: #008000;\">;<\/span><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">return<\/span> Tuple<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Create<\/span><span style=\"color: #008000;\">(<\/span><span style=\"color: #0600FF; font-weight: bold;\">false<\/span>, result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">StatusCode<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">HasValue<\/span> <span style=\"color: #008000;\">?<\/span> result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">StatusCode<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Value<\/span> <span style=\"color: #008000;\">:<\/span> <span style=\"color: #008000;\">&#8211;<\/span><span style=\"color: #FF0000;\">1<\/span>, result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Message<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #008000;\">}<\/span><\/p>\n<p>\u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">return<\/span> Tuple<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Create<\/span><span style=\"color: #008000;\">(<\/span><span style=\"color: #0600FF; font-weight: bold;\">true<\/span>, <span style=\"color: #FF0000;\">0<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">string<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Empty<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/><span style=\"color: #008000;\">}<\/span><\/div>\n<\/div>\n<p>Getting the Dictionary back from the stored JSON simply reverses the process.\u00a0 Again, I&#39;m wrapping the IGetOperationResult in a Tuple and taking care of deserializing the stored JSON into a <em>Dictionary<string, object><\/em> instance.<\/p>\n<div class=\"geshifilter\">\n<div class=\"csharp geshifilter-csharp\" style=\"font-family:monospace;\"><span style=\"color: #0600FF; font-weight: bold;\">public<\/span> <span style=\"color: #0600FF; font-weight: bold;\">static<\/span> Tuple<span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">bool<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">int<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">string<\/span>, Dictionary<span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">string<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">object<\/span><span style=\"color: #008000;\">>><\/span> GetDictionary<span style=\"color: #008000;\">(<\/span><span style=\"color: #0600FF; font-weight: bold;\">this<\/span> ICouchbaseClient client, <span style=\"color: #6666cc; font-weight: bold;\">string<\/span> key<span style=\"color: #008000;\">)<\/span><br \/><span style=\"color: #008000;\">{<\/span><br \/>\u00a0 \u00a0 var result <span style=\"color: #008000;\">=<\/span> client<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">ExecuteGet<\/span><span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">string<\/span><span style=\"color: #008000;\">><\/span><span style=\"color: #008000;\">(<\/span>key<span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><\/p>\n<p>\u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">if<\/span> <span style=\"color: #008000;\">(<\/span><span style=\"color: #008000;\">!<\/span>result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Success<\/span><span style=\"color: #008000;\">)<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #008000;\">{<\/span><br \/>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">if<\/span> <span style=\"color: #008000;\">(<\/span>result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Exception<\/span> <span style=\"color: #008000;\">!=<\/span> <span style=\"color: #0600FF; font-weight: bold;\">null<\/span><span style=\"color: #008000;\">)<\/span> <span style=\"color: #0600FF; font-weight: bold;\">throw<\/span> result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Exception<\/span><span style=\"color: #008000;\">;<\/span><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">return<\/span> Tuple<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Create<\/span><span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">bool<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">int<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">string<\/span>, Dictionary<span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">string<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">object<\/span><span style=\"color: #008000;\">>><\/span><br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #008000;\">(<\/span><span style=\"color: #0600FF; font-weight: bold;\">false<\/span>, result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">StatusCode<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">HasValue<\/span> <span style=\"color: #008000;\">?<\/span> result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">StatusCode<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Value<\/span> <span style=\"color: #008000;\">:<\/span> <span style=\"color: #008000;\">&#8211;<\/span><span style=\"color: #FF0000;\">1<\/span>, result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Message<\/span>, <span style=\"color: #0600FF; font-weight: bold;\">null<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #008000;\">}<\/span><\/p>\n<p>\u00a0 \u00a0 var dict <span style=\"color: #008000;\">=<\/span> JsonConvert<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">DeserializeObject<\/span><span style=\"color: #008000;\"><<\/span>Dictionary<span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">string<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">object<\/span><span style=\"color: #008000;\">>><\/span><span style=\"color: #008000;\">(<\/span>result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Value<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">return<\/span> Tuple<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Create<\/span><span style=\"color: #008000;\">(<\/span><span style=\"color: #0600FF; font-weight: bold;\">true<\/span>, <span style=\"color: #FF0000;\">0<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">string<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Empty<\/span>, dict<span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/><span style=\"color: #008000;\">}<\/span><\/div>\n<\/div>\n<p>Saving and retreiving is straightforward (be sure to add a using to your extension class namespace).<\/p>\n<div class=\"geshifilter\">\n<div class=\"csharp geshifilter-csharp\" style=\"font-family:monospace;\">var result <span style=\"color: #008000;\">=<\/span> client<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">StoreDictionary<\/span><span style=\"color: #008000;\">(<\/span>StoreMode<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Set<\/span>, <span style=\"color: #666666;\">&#8220;user_1&#8221;<\/span>, user1<span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/><span style=\"color: #0600FF; font-weight: bold;\">if<\/span> <span style=\"color: #008000;\">(<\/span>result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Item1<\/span><span style=\"color: #008000;\">)<\/span> <br \/><span style=\"color: #008000;\">{<\/span><br \/>\u00a0 \u00a0var dict <span style=\"color: #008000;\">=<\/span> client<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">GetDictionary<\/span><span style=\"color: #008000;\">(<\/span><span style=\"color: #666666;\">&#8220;user_1&#8221;<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Item4<\/span><span style=\"color: #008000;\">;<\/span><br \/>\u00a0 \u00a0Console<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">WriteLine<\/span><span style=\"color: #008000;\">(<\/span>dict<span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span> <span style=\"color: #008080; font-style: italic;\">\/\/should be output of Dictionary.ToString()<\/span><br \/><span style=\"color: #008000;\">}<\/span><\/div>\n<\/div>\n<p>A more interesting approach would be to take advantage of C#&#39;s new <em>dynamic<\/em> typing and the <em>ExpandoObject<\/em> class.\u00a0 These features allow developers to instruct the compiler to perform type checking at runtime, not at compile time.\u00a0 Working with JSON documents is a great use case for dynamics.<\/p>\n<p>The dynamic extension methods are almost identical, except where before there were dictionaries, now there are dynamic types.\u00a0<\/p>\n<div class=\"geshifilter\">\n<div class=\"csharp geshifilter-csharp\" style=\"font-family:monospace;\"><span style=\"color: #0600FF; font-weight: bold;\">public<\/span> <span style=\"color: #0600FF; font-weight: bold;\">static<\/span> Tuple<span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">bool<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">int<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">string<\/span><span style=\"color: #008000;\">><\/span> StoreDynamic<span style=\"color: #008000;\">(<\/span><span style=\"color: #0600FF; font-weight: bold;\">this<\/span> ICouchbaseClient client, StoreMode storeMode,<br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #6666cc; font-weight: bold;\">string<\/span> key, ExpandoObject obj<span style=\"color: #008000;\">)<\/span><br \/><span style=\"color: #008000;\">{<\/span><br \/>\u00a0 \u00a0 var json <span style=\"color: #008000;\">=<\/span> JsonConvert<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">SerializeObject<\/span><span style=\"color: #008000;\">(<\/span>obj<span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/>\u00a0 \u00a0 var result <span style=\"color: #008000;\">=<\/span> client<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">ExecuteStore<\/span><span style=\"color: #008000;\">(<\/span>storeMode, key, json<span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><\/p>\n<p>\u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">if<\/span> <span style=\"color: #008000;\">(<\/span><span style=\"color: #008000;\">!<\/span>result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Success<\/span><span style=\"color: #008000;\">)<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #008000;\">{<\/span><br \/>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">if<\/span> <span style=\"color: #008000;\">(<\/span>result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Exception<\/span> <span style=\"color: #008000;\">!=<\/span> <span style=\"color: #0600FF; font-weight: bold;\">null<\/span><span style=\"color: #008000;\">)<\/span> <span style=\"color: #0600FF; font-weight: bold;\">throw<\/span> result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Exception<\/span> <span style=\"color: #0600FF; font-weight: bold;\">as<\/span> Exception<span style=\"color: #008000;\">;<\/span><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">return<\/span> Tuple<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Create<\/span><span style=\"color: #008000;\">(<\/span><span style=\"color: #0600FF; font-weight: bold;\">false<\/span>, result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">StatusCode<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">HasValue<\/span> <span style=\"color: #008000;\">?<\/span> result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">StatusCode<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Value<\/span> <span style=\"color: #008000;\">:<\/span> <span style=\"color: #008000;\">&#8211;<\/span><span style=\"color: #FF0000;\">1<\/span>, result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Message<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #008000;\">}<\/span><\/p>\n<p>\u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">return<\/span> Tuple<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Create<\/span><span style=\"color: #008000;\">(<\/span><span style=\"color: #0600FF; font-weight: bold;\">true<\/span>, <span style=\"color: #FF0000;\">0<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">string<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Empty<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/><span style=\"color: #008000;\">}<\/span><\/p>\n<p><span style=\"color: #0600FF; font-weight: bold;\">public<\/span> <span style=\"color: #0600FF; font-weight: bold;\">static<\/span> Tuple<span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">bool<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">int<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">string<\/span>, ExpandoObject<span style=\"color: #008000;\">><\/span> GetDynamic<span style=\"color: #008000;\">(<\/span><span style=\"color: #0600FF; font-weight: bold;\">this<\/span> ICouchbaseClient client, <span style=\"color: #6666cc; font-weight: bold;\">string<\/span> key<span style=\"color: #008000;\">)<\/span><br \/><span style=\"color: #008000;\">{<\/span><br \/>\u00a0 \u00a0 var result <span style=\"color: #008000;\">=<\/span> client<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">ExecuteGet<\/span><span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">string<\/span><span style=\"color: #008000;\">><\/span><span style=\"color: #008000;\">(<\/span>key<span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><\/p>\n<p>\u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">if<\/span> <span style=\"color: #008000;\">(<\/span><span style=\"color: #008000;\">!<\/span>result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Success<\/span><span style=\"color: #008000;\">)<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #008000;\">{<\/span><br \/>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">if<\/span> <span style=\"color: #008000;\">(<\/span>result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Exception<\/span> <span style=\"color: #008000;\">!=<\/span> <span style=\"color: #0600FF; font-weight: bold;\">null<\/span><span style=\"color: #008000;\">)<\/span> <span style=\"color: #0600FF; font-weight: bold;\">throw<\/span> result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Exception<\/span><span style=\"color: #008000;\">;<\/span><\/p>\n<p>\u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">return<\/span> Tuple<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Create<\/span><span style=\"color: #008000;\"><<\/span><span style=\"color: #6666cc; font-weight: bold;\">bool<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">int<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">string<\/span>, ExpandoObject<span style=\"color: #008000;\">><\/span><br \/>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 <span style=\"color: #008000;\">(<\/span><span style=\"color: #0600FF; font-weight: bold;\">false<\/span>, result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">StatusCode<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">HasValue<\/span> <span style=\"color: #008000;\">?<\/span> result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">StatusCode<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Value<\/span> <span style=\"color: #008000;\">:<\/span> <span style=\"color: #008000;\">&#8211;<\/span><span style=\"color: #FF0000;\">1<\/span>, result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Message<\/span>, <span style=\"color: #0600FF; font-weight: bold;\">null<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #008000;\">}<\/span><\/p>\n<p>\u00a0 \u00a0 var obj <span style=\"color: #008000;\">=<\/span> JsonConvert<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">DeserializeObject<\/span><span style=\"color: #008000;\"><<\/span>ExpandoObject<span style=\"color: #008000;\">><\/span><span style=\"color: #008000;\">(<\/span>result<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Value<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/>\u00a0 \u00a0 <span style=\"color: #0600FF; font-weight: bold;\">return<\/span> Tuple<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Create<\/span><span style=\"color: #008000;\">(<\/span><span style=\"color: #0600FF; font-weight: bold;\">true<\/span>, <span style=\"color: #FF0000;\">0<\/span>, <span style=\"color: #6666cc; font-weight: bold;\">string<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Empty<\/span>, obj<span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/><span style=\"color: #008000;\">}<\/span><\/div>\n<\/div>\n<p>Using dynamic instances in your code, you can then save and retrieve data to and from Couchbase Server.\u00a0 Note that you could also read any JSON document into an ExpandoObject using the code approach below.\u00a0 To test that, you can call <em>GetDynamic <\/em>with a key of &#8220;user_1.&#8221;<\/p>\n<div class=\"geshifilter\">\n<div class=\"csharp geshifilter-csharp\" style=\"font-family:monospace;\">dynamic user2 <span style=\"color: #008000;\">=<\/span> <a href=\"https:\/\/www.google.com\/search?q=new+msdn.microsoft.com\"><span style=\"color: #008000;\">new<\/span><\/a> ExpandoObject<span style=\"color: #008000;\">(<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/>user2<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Username<\/span> <span style=\"color: #008000;\">=<\/span> <span style=\"color: #666666;\">&#8220;jzablocki&#8221;<\/span><span style=\"color: #008000;\">;<\/span><br \/>user2<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Preferences<\/span> <span style=\"color: #008000;\">=<\/span> <a href=\"https:\/\/www.google.com\/search?q=new+msdn.microsoft.com\"><span style=\"color: #008000;\">new<\/span><\/a> ExpandoObject<span style=\"color: #008000;\">(<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/>user2<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Preferences<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Theme<\/span> <span style=\"color: #008000;\">=<\/span> <span style=\"color: #666666;\">&#8220;green&#8221;<\/span><span style=\"color: #008000;\">;<\/span><br \/>user2<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Preferences<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">TimeZone<\/span> <span style=\"color: #008000;\">=<\/span> <span style=\"color: #666666;\">&#8220;EST&#8221;<\/span><span style=\"color: #008000;\">;<\/span><\/p>\n<p>client<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">StoreDynamic<\/span><span style=\"color: #008000;\">(<\/span>StoreMode<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Set<\/span>, <span style=\"color: #666666;\">&#8220;user_2&#8221;<\/span>, user2 <span style=\"color: #0600FF; font-weight: bold;\">as<\/span> ExpandoObject<span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/>var getResult <span style=\"color: #008000;\">=<\/span> client<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">GetDynamic<\/span><span style=\"color: #008000;\">(<\/span><span style=\"color: #666666;\">&#8220;user_2&#8221;<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/><span style=\"color: #0600FF; font-weight: bold;\">if<\/span> <span style=\"color: #008000;\">(<\/span>getResult<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Item1<\/span><span style=\"color: #008000;\">)<\/span><br \/><span style=\"color: #008000;\">{<\/span><br \/>\u00a0 \u00a0 dynamic item <span style=\"color: #008000;\">=<\/span> getResult<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Item4<\/span><span style=\"color: #008000;\">;<\/span><br \/>\u00a0 \u00a0 Console<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">WriteLine<\/span><span style=\"color: #008000;\">(<\/span>item<span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Preferences<\/span><span style=\"color: #008000;\">.<\/span><span style=\"color: #0000FF;\">Theme<\/span><span style=\"color: #008000;\">)<\/span><span style=\"color: #008000;\">;<\/span><br \/><span style=\"color: #008000;\">}<\/span><\/div>\n<\/div>\n<p>There are alternate approaches toward the dynamic extensions that require casting, because of the limitations of calling an extension method with dynamic arguments.\u00a0 To simplify things, I&#39;ve stuck with <em>ExpandoObject<\/em> arguments.\u00a0<\/p>\n<div>C# obviously isn&#39;t a purely dynamic language, and therefore some of the methods are a less terse than they would be in their purely late bound counterparts.\u00a0 However, these methods demonstrate that you don&#39;t have to give up the full richness of a schemaless document-oriented database just because your language is statically typed, as long as that language is C# of course&#8230;<\/div>\n","protected":false},"excerpt":{"rendered":"<p>One of the significant benefits of working with Couchbase Server 2.0 is its flexible schema.\u00a0 Documents are stored as JSON, allowing for implicitly structured records that impose no order on each other.\u00a0 In the real world, that &#8220;implicit structure&#8221; comes [&hellip;]<\/p>\n","protected":false},"author":22,"featured_media":13873,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"ppma_author":[8980],"class_list":["post-1709","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.8 (Yoast SEO v25.8) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Moving No Schema up the Stack with C# and Dynamic Types - The Couchbase Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Moving No Schema up the Stack with C# and Dynamic Types\" \/>\n<meta property=\"og:description\" content=\"One of the significant benefits of working with Couchbase Server 2.0 is its flexible schema.\u00a0 Documents are stored as JSON, allowing for implicitly structured records that impose no order on each other.\u00a0 In the real world, that &#8220;implicit structure&#8221; comes [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-16T19:05:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/11\/couchbase-nosql-dbaas.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1800\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"John Zablocki, NET. SDK Developer, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"John Zablocki, NET. SDK Developer, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/\"},\"author\":{\"name\":\"John Zablocki, NET. SDK Developer, Couchbase\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/ee312fb775c13d20a32f1d455888a282\"},\"headline\":\"Moving No Schema up the Stack with C# and Dynamic Types\",\"datePublished\":\"2014-12-16T19:05:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/\"},\"wordCount\":989,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/\",\"name\":\"Moving No Schema up the Stack with C# and Dynamic Types - The Couchbase Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"datePublished\":\"2014-12-16T19:05:13+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#primaryimage\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png\",\"width\":1800,\"height\":630},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.couchbase.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Moving No Schema up the Stack with C# and Dynamic Types\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#website\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\/\/www.couchbase.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"contentUrl\":\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/ee312fb775c13d20a32f1d455888a282\",\"name\":\"John Zablocki, NET. SDK Developer, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/201925d9efc4992ce80385b76fdea34b\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8c5a77152c796c424a3f7f6d9fa31a999a7fe115d64c2acc93c4c0c014e6512a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8c5a77152c796c424a3f7f6d9fa31a999a7fe115d64c2acc93c4c0c014e6512a?s=96&d=mm&r=g\",\"caption\":\"John Zablocki, NET. SDK Developer, Couchbase\"},\"description\":\"John Zablocki is a NET. SDK Developer at Couchbase. John is also the organizer of Beantown ALT.NET and a former adjunct at Fairfield University. You can also check out the book on Amazon named \\\"Couchbase Essentials\\\" which explains how to install and configure Couchbase Server.\",\"url\":\"https:\/\/www.couchbase.com\/blog\/author\/john-zablocki\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Moving No Schema up the Stack with C# and Dynamic Types - The Couchbase Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/","og_locale":"en_US","og_type":"article","og_title":"Moving No Schema up the Stack with C# and Dynamic Types","og_description":"One of the significant benefits of working with Couchbase Server 2.0 is its flexible schema.\u00a0 Documents are stored as JSON, allowing for implicitly structured records that impose no order on each other.\u00a0 In the real world, that &#8220;implicit structure&#8221; comes [&hellip;]","og_url":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/","og_site_name":"The Couchbase Blog","article_published_time":"2014-12-16T19:05:13+00:00","og_image":[{"width":1800,"height":630,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2022\/11\/couchbase-nosql-dbaas.png","type":"image\/png"}],"author":"John Zablocki, NET. SDK Developer, Couchbase","twitter_card":"summary_large_image","twitter_misc":{"Written by":"John Zablocki, NET. SDK Developer, Couchbase","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/"},"author":{"name":"John Zablocki, NET. SDK Developer, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/ee312fb775c13d20a32f1d455888a282"},"headline":"Moving No Schema up the Stack with C# and Dynamic Types","datePublished":"2014-12-16T19:05:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/"},"wordCount":989,"commentCount":2,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/","url":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/","name":"Moving No Schema up the Stack with C# and Dynamic Types - The Couchbase Blog","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","datePublished":"2014-12-16T19:05:13+00:00","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2022\/11\/couchbase-nosql-dbaas.png","width":1800,"height":630},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/moving-no-schema-stack-c-and-dynamic-types\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Moving No Schema up the Stack with C# and Dynamic Types"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/ee312fb775c13d20a32f1d455888a282","name":"John Zablocki, NET. SDK Developer, Couchbase","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/image\/201925d9efc4992ce80385b76fdea34b","url":"https:\/\/secure.gravatar.com\/avatar\/8c5a77152c796c424a3f7f6d9fa31a999a7fe115d64c2acc93c4c0c014e6512a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8c5a77152c796c424a3f7f6d9fa31a999a7fe115d64c2acc93c4c0c014e6512a?s=96&d=mm&r=g","caption":"John Zablocki, NET. SDK Developer, Couchbase"},"description":"John Zablocki is a NET. SDK Developer at Couchbase. John is also the organizer of Beantown ALT.NET and a former adjunct at Fairfield University. You can also check out the book on Amazon named \"Couchbase Essentials\" which explains how to install and configure Couchbase Server.","url":"https:\/\/www.couchbase.com\/blog\/author\/john-zablocki\/"}]}},"authors":[{"term_id":8980,"user_id":22,"is_guest":0,"slug":"john-zablocki","display_name":"John Zablocki, NET. SDK Developer, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/8c5a77152c796c424a3f7f6d9fa31a999a7fe115d64c2acc93c4c0c014e6512a?s=96&d=mm&r=g","author_category":"","last_name":"Zablocki","first_name":"John","job_title":"","user_url":"","description":"John Zablocki is a NET. SDK Developer at Couchbase. John is also the organizer of Beantown ALT.NET and a former adjunct at Fairfield University.\r\nYou can also check out the book on Amazon named \"Couchbase Essentials\" which explains how to install and configure Couchbase Server."}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/1709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/22"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=1709"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/1709\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/13873"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=1709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=1709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=1709"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=1709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}