Exemple #1
0
        /// <summary>
        /// Constructor. Provide a type derived from DocCollectionSettings to identify the collection.
        /// </summary>
        /// <param name="settings"></param>
        public DocCollection(TSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }
            if (settings.AccessKey == null)
            {
                throw new ArgumentNullException(nameof(settings.AccessKey));
            }
            if (settings.DatabaseId == null)
            {
                throw new ArgumentNullException(nameof(settings.DatabaseId));
            }
            if (settings.EndpointUri == null)
            {
                throw new ArgumentNullException(nameof(settings.EndpointUri));
            }
            if (settings.CollectionId == null)
            {
                throw new ArgumentNullException(nameof(settings.CollectionId));
            }

            //can be null, useful for testing to set it to mock
            //pass one in to share it across repos (recommended)
            _docClient = settings.DocumentClient;

            _settings = settings;

            if (settings.InitializeAutomatically)
            {
                // make sure db and collection exist...
                InitDocumentDBAsync().GetAwaiter().GetResult();
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="settings"></param>
        public DocRepo(DocCollectionSettings settings)
        {
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            //can be null, useful for testing to set it to mock
            //pass one in to share it across repos (recommended)
            _docClient = settings.DocumentClient;

            _settings = settings;
        }