-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
3 - M (<= 1 month)
-
2024
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 };