/// <summary>
        /// Creates the new collection.
        /// </summary>
        /// <param name="client">The client.</param>
        /// <param name="database">The database.</param>
        /// <param name="collectionId">The collection identifier.</param>
        /// <param name="collectionSpec">The collection spec.</param>
        /// <returns></returns>
        public static async Task <DocumentCollection> CreateNewCollection(
            IDocumentClient client,
            Database database,
            string collectionId,
            DocumentCollectionSpec collectionSpec)
        {
            DocumentCollection collectionDefinition = new DocumentCollection {
                Id = collectionId
            };

            int throughput = 400;

            if (collectionSpec != null)
            {
                //Partitions
                if (collectionSpec != null && collectionSpec.CollectionIsPartitioned)
                {
                    collectionDefinition.PartitionKey.Paths.Add(collectionSpec.PartitionPath);
                }

                //Set throughput for new collection
                throughput = collectionSpec.Throughput;
            }

            //Create the Collection
            DocumentCollection collection = await
                                            client.CreateDocumentCollectionAsync(
                database.SelfLink,
                collectionDefinition,
                new RequestOptions { OfferThroughput = throughput }
                );

            return(collection);
        }
        /// <summary>
        /// Returns a refernce to a collection with a DocumentDb database, or
        /// creates if it does not exist
        /// </summary>
        /// <param name="Client">DocumentDb client connection</param>
        /// <param name="db">Reference to the containing DocumentDb database</param>
        /// <param name="collectionId">The Id of the Collection to return a reference for</param>
        /// <param name="collectionSpec">Specifications for the Collection (used to create if it does not exist)</param>
        /// <returns></returns>
        public static async Task <DocumentCollection> GetOrCreateCollectionAsync(IDocumentClient Client,
                                                                                 Database db, string collectionId, DocumentCollectionSpec collectionSpec = null)
        {
            DocumentCollection collection = Client.CreateDocumentCollectionQuery(db.SelfLink).Where(c => c.Id == collectionId).ToArray().FirstOrDefault();

            if (collection == null)
            {
                collection = await CreateNewCollection(Client, db, collectionId, collectionSpec);
            }
            return(collection);
        }