Changed in version 12.2.0: RealmValue
can hold lists and dictionaries of mixed data.
The RealmValue
data type is a mixed data type, and can represent any other valid Realm data type except an embedded object or a set. You can create collections (lists, sets, and dictionaries) of type RealmValue
:
RealmValue myList = new List<Inventory>();var rvList = new List<RealmValue>();var rvDict = new Dictionary<string, RealmValue>();
Note
You cannot create a nullable RealmValue
. However, if you want a RealmValue
property to contain a null value, you can use the special RealmValue.Null
property.
The following code demonstrates creating a RealmValue
property in a class that inherits from IRealmObject
and then setting and getting the value of that property:
public partial class MyRealmValueObject : IRealmObject{ [PrimaryKey] [MapTo("_id")] public Guid Id { get; set; } public RealmValue MyValue { get; set; } private void TestRealmValue() { var obj = new MyRealmValueObject(); obj.MyValue = RealmValue.Null; obj.MyValue = 1; obj.MyValue = "abc"; if (obj.MyValue.Type == RealmValueType.String) { var myString = obj.MyValue.AsString(); } }
In version 12.2.0 and later, a RealmValue
data type can hold collections (a list or dictionary, but not a set) of RealmValue
elements. You can use mixed collections to model unstructured or variable data. For more information, refer to Define Unstructured Data.
You can nest mixed collections up to 100 levels.
You can query mixed collection properties and register a listener for changes, as you would a normal collection.
You can find and update individual mixed collection elements
You cannot store sets or embedded objects in mixed collections.
To use mixed collections, define the RealmValue
type property in your data model. Then, set the property as a list or dictionary.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4