Show / Hide Table of Contents

    Class FrozenObjectsExtensions

    A set of extension methods on top of RealmObject.

    Inheritance
    Object
    FrozenObjectsExtensions
    Namespace: Realms
    Assembly: Realm.dll
    Syntax
    public static class FrozenObjectsExtensions

    Methods

    | Improve this Doc View Source

    Freeze<T>(T)

    Returns a frozen snapshot of this object. The frozen copy can be read and queried from any thread without throwing an exception.

    Freezing a RealmObject 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 static T Freeze<T>(this T realmObj)
        where T : RealmObject
    Parameters
    Type Name Description
    T realmObj

    The RealmObject instance that you want to create a frozen version of.

    Returns
    Type Description
    T

    A new frozen instance of the passed in object or the object itself if it was already frozen.

    Type Parameters
    Name Description
    T

    The type of the RealmObject.

    See Also
    FreezeInPlace()
    | Improve this Doc View Source

    Freeze<T>(IList<T>)

    Creates a frozen snapshot of this list. The frozen copy can be read and iterated over from any thread. If the list is not managed, a RealmException will be thrown.

    Freezing a list also creates a frozen Realm which has its own lifecycle, but if the live Realm that spawned the original list is fully closed (i.e. all instances across all threads are closed), the frozen Realm and list will be closed as well.

    Frozen lists can be read and iterated 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 static IList<T> Freeze<T>(this IList<T> list)
    Parameters
    Type Name Description
    IList<T> list

    The list you want to create a frozen copy of.

    Returns
    Type Description
    IList<T>

    A frozen copy of this list.

    Type Parameters
    Name Description
    T

    Type of the objects in the list.

    | Improve this Doc View Source

    Freeze<T>(IQueryable<T>)

    Creates a frozen snapshot of this query. The frozen copy can be read and queried from any thread. If the query is not managed (i.e. not a result of All<T>() invocation), a RealmException will be thrown.

    Freezing a query also creates a frozen Realm which has its own lifecycle, but if the live Realm that spawned the original query is fully closed (i.e. all instances across all threads are closed), the frozen Realm and query will be closed as well.

    Frozen queries can be read and iterated 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 static IQueryable<T> Freeze<T>(this IQueryable<T> query)
        where T : RealmObject
    Parameters
    Type Name Description
    IQueryable<T> query

    The query you want to create a frozen copy of.

    Returns
    Type Description
    IQueryable<T>

    A frozen copy of this query.

    Type Parameters
    Name Description
    T

    The type of the RealmObject in the query.

    • Improve this Doc
    • View Source
    Back to top Copyright © 2020 Realm
    Generated by DocFX