Beispiel #1
0
        /// <summary>
        /// Remove objects matcing a query from the realm.
        /// </summary>
        /// <typeparam name="T">Type of the objects to remove.</typeparam>
        /// <param name="range">The query to match for.</param>
        public void RemoveRange <T>(RealmResults <T> range) where T : RealmObject
        {
            if (!IsInTransaction)
            {
                throw new RealmOutsideTransactionException("Cannot remove Realm objects outside write transactions");
            }

            NativeResults.clear(range.ResultsHandle);
        }
Beispiel #2
0
        /// <summary>
        /// Remove all objects of all types managed by this realm.
        /// </summary>
        public void RemoveAll()
        {
            if (!IsInTransaction)
            {
                throw new RealmOutsideTransactionException("Cannot remove all Realm objects outside write transactions");
            }

            var objectClasses = Config.ObjectClasses ?? RealmObjectClasses;

            foreach (var objectClass in objectClasses)
            {
                var resultsHandle = MakeResultsForTable(objectClass);
                NativeResults.clear(resultsHandle);
            }
        }