Exemple #1
0
        /// <summary>
        /// After reading all existing elements from the database, do the queued operations
        /// (adds or removes) on the underlying collection.
        /// </summary>
        /// <param name="collection">The collection.</param>
        public static void ApplyQueuedOperations(this IPersistentCollection collection)
        {
            if (collection is AbstractPersistentCollection baseImpl)
            {
                baseImpl.ApplyQueuedOperations();
                return;
            }

            // Fallback on reflection for custom implementations
            var collectionType = collection.GetType();
            var applyQueuedOperationsMethod = collectionType.GetMethod(
                nameof(AbstractPersistentCollection.ApplyQueuedOperations),
                Array.Empty <System.Type>());

            if (applyQueuedOperationsMethod != null)
            {
                applyQueuedOperationsMethod.Invoke(collection, Array.Empty <object>());
                return;
            }

            Logger.Warn(
                "{0} does not implement 'void ApplyQueuedOperations()'. It should move any queued operations" +
                "processing out of 'AfterInitialize' and put it in a 'public void ApplyQueuedOperations()'.",
                collectionType);
        }