Uploaded image for project: 'Realm .NET SDK'
  1. Realm .NET SDK
  2. RNET-250

Support anonymous object syntax for the dynamic API

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      With embedded objects in v10, using the dynamic API becomes a little clunky. The proposed syntax looks something like:

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      var parent = realm.DynamicApi.Create("Parent");
      var child = realm.DynamicApi.CreateEmbeddedObjectForProperty(parent, "Child");
      child.Value = 123;
      
      var childInList = realm.DynamicApi.AddEmbeddedObjectToList(parent.Children);
      childInList.Value = 456;
      
      var updatedChildInList = realm.DynamicApi.SetEmbeddedObjectInList(parent.Children, 5);
      updatedChildInList.Value = 789;
      

      To simplify that, we can allow using anonymous objects to get syntax, similar to what realm-js offers.

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      var parent = new
      {
          Id = 1,
          Child = new
          {
              Value = 123
          }
      };
      
      var managedParent = realm.DynamicApi.Add("Parent", parent);
      managedParent.Child = new { Value = 999 };
      
      managedParent.Children.Add(new { Value = 456 });
      
      managedParent.Children[5] = new { Value = 789 };
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            nikola.irinchev@mongodb.com Nikola Irinchev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: