Class RealmObjectBase
Base for any object that can be persisted in a Realm.
Inheritance
RealmObjectBase
Assembly: Realm.dll
Syntax
[Preserve(AllMembers = true, Conditional = false)]
[Serializable]
public abstract class RealmObjectBase : INotifyPropertyChanged, IThreadConfined, NotificationsHelper.INotifiable, IReflectableType
Properties
|
Improve this Doc
View Source
BacklinksCount
Gets the number of objects referring to this one via either a to-one or to-many relationship.
Declaration
public int BacklinksCount { get; }
Property Value
|
Improve this Doc
View Source
IsFrozen
Gets a value indicating whether this object is frozen. Frozen objects are immutable
and will not update when writes are made to the Realm. Unlike live objects, frozen
objects can be used across threads.
Declaration
public bool IsFrozen { get; }
Property Value
See Also
|
Improve this Doc
View Source
IsManaged
Gets a value indicating whether the object has been associated with a Realm, either at creation or via
Add<T>(T, Boolean).
Declaration
public bool IsManaged { get; }
Property Value
Type |
Description |
Boolean |
true if object belongs to a Realm; false if standalone.
|
|
Improve this Doc
View Source
IsValid
Gets a value indicating whether this object is managed and represents a row in the database.
If a managed object has been removed from the Realm, it is no longer valid and accessing properties on it
will throw an exception.
Unmanaged objects are always considered valid.
Declaration
public bool IsValid { get; }
Property Value
Type |
Description |
Boolean |
true if managed and part of the Realm or unmanaged; false if managed but deleted.
|
|
Improve this Doc
View Source
ObjectSchema
Gets the ObjectSchema instance that describes how the Realm this object belongs to sees it.
Declaration
public ObjectSchema ObjectSchema { get; }
Property Value
Type |
Description |
ObjectSchema |
A collection of properties describing the underlying schema of this object.
|
|
Improve this Doc
View Source
Realm
Gets the Realm instance this object belongs to, or null
if it is unmanaged.
Declaration
public Realm Realm { get; }
Property Value
Type |
Description |
Realm |
The Realm instance this object belongs to.
|
Methods
|
Improve this Doc
View Source
Finalize()
Declaration
protected void Finalize()
|
Improve this Doc
View Source
FreezeInPlace()
Freezes this object in place. The frozen object can be accessed from any thread.
Freezing a RealmObjectBase also creates a frozen Realm which has its own lifecycle, but if the live Realm that spawned the
original object is fully closed (i.e. all instances across all threads are closed), the frozen Realm and
object will be closed as well.
Frozen objects can be queried as normal, but trying to mutate it in any way or attempting to register a listener will
throw a RealmFrozenException.
Note: Keeping a large number of frozen objects with different versions alive can have a negative impact on the filesize
of the Realm. In order to avoid such a situation it is possible to set MaxNumberOfActiveVersions.
Declaration
public void FreezeInPlace()
See Also
|
Improve this Doc
View Source
GetBacklinks(String, String)
Returns all the objects that link to this object in the specified relationship.
Declaration
public IQueryable<dynamic> GetBacklinks(string objectType, string property)
Parameters
Type |
Name |
Description |
String |
objectType |
The type of the object that is on the other end of the relationship.
|
String |
property |
The property that is on the other end of the relationship.
|
Returns
Type |
Description |
IQueryable<Object> |
A queryable collection containing all objects of objectType that link to the current object via property .
|
|
Improve this Doc
View Source
GetBacklinks<T>(String)
Declaration
protected IQueryable<T> GetBacklinks<T>(string propertyName)
where T : RealmObjectBase
Parameters
Type |
Name |
Description |
String |
propertyName |
|
Returns
Type Parameters
|
Improve this Doc
View Source
GetByteArrayValue(String)
Declaration
protected byte[] GetByteArrayValue(string propertyName)
Parameters
Type |
Name |
Description |
String |
propertyName |
|
Returns
|
Improve this Doc
View Source
GetListValue<T>(String)
Declaration
protected IList<T> GetListValue<T>(string propertyName)
Parameters
Type |
Name |
Description |
String |
propertyName |
|
Returns
Type |
Description |
IList<T> |
|
Type Parameters
|
Improve this Doc
View Source
GetNullableRealmIntegerValue<T>(String)
Declaration
protected RealmInteger<T>? GetNullableRealmIntegerValue<T>(string propertyName)
where T : struct, IFormattable, IComparable<T>
Parameters
Type |
Name |
Description |
String |
propertyName |
|
Returns
Type Parameters
|
Improve this Doc
View Source
GetObjectValue<T>(String)
Declaration
protected T GetObjectValue<T>(string propertyName)
where T : RealmObjectBase
Parameters
Type |
Name |
Description |
String |
propertyName |
|
Returns
Type Parameters
|
Improve this Doc
View Source
GetPrimitiveValue<T>(String, PropertyType)
Declaration
protected T GetPrimitiveValue<T>(string propertyName, PropertyType propertyType)
Parameters
Returns
Type Parameters
|
Improve this Doc
View Source
GetRealmIntegerValue<T>(String)
Declaration
protected RealmInteger<T> GetRealmIntegerValue<T>(string propertyName)
where T : struct, IFormattable, IComparable<T>
Parameters
Type |
Name |
Description |
String |
propertyName |
|
Returns
Type Parameters
|
Improve this Doc
View Source
GetStringValue(String)
Declaration
protected string GetStringValue(string propertyName)
Parameters
Type |
Name |
Description |
String |
propertyName |
|
Returns
|
Improve this Doc
View Source
GetTypeInfo()
Declaration
public TypeInfo GetTypeInfo()
Returns
|
Improve this Doc
View Source
OnManaged()
Called when the object has been managed by a Realm.
Declaration
protected virtual void OnManaged()
|
Improve this Doc
View Source
OnPropertyChanged(String)
Called when a property has changed on this class.
Declaration
protected virtual void OnPropertyChanged(string propertyName)
Parameters
Type |
Name |
Description |
String |
propertyName |
The name of the property.
|
Examples
class MyClass : RealmObject
{
public int StatusCodeRaw { get; set; }
public StatusCodeEnum StatusCode => (StatusCodeEnum)StatusCodeRaw;
protected override void OnPropertyChanged(string propertyName)
{
if (propertyName == nameof(StatusCodeRaw))
{
RaisePropertyChanged(nameof(StatusCode));
}
}
}
Here, we have a computed property that depends on a persisted one. In order to notify any PropertyChanged
subscribers that StatusCode
has changed, we override OnPropertyChanged(String) and
raise PropertyChanged manually by calling RaisePropertyChanged(String).
|
Improve this Doc
View Source
RaisePropertyChanged(String)
Allows you to raise the PropertyChanged event.
Declaration
protected void RaisePropertyChanged(string propertyName = null)
Parameters
Type |
Name |
Description |
String |
propertyName |
The name of the property that has changed. If not specified, we'll use the caller name.
|
|
Improve this Doc
View Source
SetByteArrayValue(String, Byte[])
Declaration
protected void SetByteArrayValue(string propertyName, byte[] value)
Parameters
Type |
Name |
Description |
String |
propertyName |
|
Byte[] |
value |
|
|
Improve this Doc
View Source
SetNullableRealmIntegerValue<T>(String, Nullable<RealmInteger<T>>)
Declaration
protected void SetNullableRealmIntegerValue<T>(string propertyName, RealmInteger<T>? value)
where T : struct, IComparable<T>, IFormattable
Parameters
Type Parameters
|
Improve this Doc
View Source
SetNullableRealmIntegerValueUnique<T>(String, Nullable<RealmInteger<T>>)
Declaration
protected void SetNullableRealmIntegerValueUnique<T>(string propertyName, RealmInteger<T>? value)
where T : struct, IComparable<T>, IFormattable
Parameters
Type Parameters
|
Improve this Doc
View Source
SetObjectValue<T>(String, T)
Declaration
protected void SetObjectValue<T>(string propertyName, T value)
where T : RealmObjectBase
Parameters
Type |
Name |
Description |
String |
propertyName |
|
T |
value |
|
Type Parameters
|
Improve this Doc
View Source
SetPrimitiveValue<T>(String, T, PropertyType)
Declaration
protected void SetPrimitiveValue<T>(string propertyName, T value, PropertyType propertyType)
Parameters
Type Parameters
|
Improve this Doc
View Source
SetPrimitiveValueUnique<T>(String, T, PropertyType)
Declaration
protected void SetPrimitiveValueUnique<T>(string propertyName, T value, PropertyType propertyType)
Parameters
Type Parameters
|
Improve this Doc
View Source
SetRealmIntegerValue<T>(String, RealmInteger<T>)
Declaration
protected void SetRealmIntegerValue<T>(string propertyName, RealmInteger<T> value)
where T : struct, IComparable<T>, IFormattable
Parameters
Type Parameters
|
Improve this Doc
View Source
SetRealmIntegerValueUnique<T>(String, RealmInteger<T>)
Declaration
protected void SetRealmIntegerValueUnique<T>(string propertyName, RealmInteger<T> value)
where T : struct, IComparable<T>, IFormattable
Parameters
Type Parameters
|
Improve this Doc
View Source
SetStringValue(String, String)
Declaration
protected void SetStringValue(string propertyName, string value)
Parameters
|
Improve this Doc
View Source
SetStringValueUnique(String, String)
Declaration
protected void SetStringValueUnique(string propertyName, string value)
Parameters
Events
|
Improve this Doc
View Source
PropertyChanged
Occurs when a property value changes.
Declaration
public event PropertyChangedEventHandler PropertyChanged
Event Type
Implements
Extension Methods