Beispiel #1
0
        /// <summary>
        /// Loads the client objects.
        /// </summary>
        /// <param name="clientObjects">Client objects to load.</param>
        /// <typeparam name="T">Object type inheriting <see cref="ClientObject"/>.</typeparam>
        /// <returns>Returns the list of client objects.</returns>
        public IEnumerable <T> LoadQuery <T>(ClientObjectCollection <T> clientObjects) where T : ClientObject
        {
            if (this.ContextInstance == null)
            {
                throw new InvalidOperationException();
            }

            if (clientObjects == null)
            {
                throw new ArgumentNullException(nameof(clientObjects));
            }

            var results = this.ContextInstance.LoadQuery(clientObjects);

            return(results);
        }
Beispiel #2
0
        /// <summary>
        /// Loads the client objects asynchronously.
        /// </summary>
        /// <param name="clientObjects">Client objects to load.</param>
        /// <typeparam name="T">Object type inheriting <see cref="ClientObject"/>.</typeparam>
        /// <returns>Returns the list of client objects.</returns>
        public Task <IEnumerable <T> > LoadQueryAsync <T>(ClientObjectCollection <T> clientObjects) where T : ClientObject
        {
            if (this.ContextInstance == null)
            {
                throw new InvalidOperationException();
            }

            if (clientObjects == null)
            {
                throw new ArgumentNullException(nameof(clientObjects));
            }

            IEnumerable <T> results = null;

            Task.Factory.StartNew(() => { results = this.LoadQuery(clientObjects); });
            return(Task.FromResult(results));
        }
        /// <summary>
        /// Loads the client objects asynchronously.
        /// </summary>
        /// <param name="context"><see cref="ClientContext"/> instance to extend.</param>
        /// <param name="clientObjects">Client objects to load.</param>
        /// <typeparam name="T">Object type inheriting <see cref="ClientObject"/>.</typeparam>
        /// <returns>Returns the list of client objects.</returns>
        public static Task <IEnumerable <T> > LoadQueryAsync <T>(this ClientContext context, ClientObjectCollection <T> clientObjects)
            where T : ClientObject
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (clientObjects == null)
            {
                throw new ArgumentNullException(nameof(clientObjects));
            }

            IEnumerable <T> results = null;

            Task.Factory.StartNew(() => { results = context.LoadQuery(clientObjects); });
            return(Task.FromResult(results));
        }