private async Task <LuceneIndexSettingsDocument> LoadDocumentAsync(ISession session)
        {
            var document = await session.Query <LuceneIndexSettingsDocument>().FirstOrDefaultAsync();

            if (document == null)
            {
                document = new LuceneIndexSettingsDocument();
            }

            return(document);
        }
Esempio n. 2
0
        /// <summary>
        /// Returns the document from the cache or creates a new one. The result should not be updated.
        /// </summary>
        private async Task <LuceneIndexSettingsDocument> GetDocumentAsync()
        {
            if (_document == null || (_changeToken?.HasChanged ?? true))
            {
                _changeToken = ChangeToken;

                var document = await SessionHelper.GetForCachingAsync <LuceneIndexSettingsDocument>();

                foreach (var name in document.LuceneIndexSettings.Keys)
                {
                    document.LuceneIndexSettings[name].IndexName  = name;
                    document.LuceneIndexSettings[name].IsReadonly = true;
                }

                _document = document;
            }

            return(_document);
        }
        /// <summary>
        /// Returns the document from the cache or creates a new one. The result should not be updated.
        /// </summary>
        private async Task <LuceneIndexSettingsDocument> GetDocumentAsync()
        {
            if (_document == null || (_changeToken?.HasChanged ?? true))
            {
                _changeToken = ChangeToken;

                LuceneIndexSettingsDocument document;

                using (var session = _store.CreateSession())
                {
                    document = await LoadDocumentAsync(session);
                }

                foreach (var name in document.LuceneIndexSettings.Keys)
                {
                    document.LuceneIndexSettings[name].IndexName  = name;
                    document.LuceneIndexSettings[name].IsReadonly = true;
                }

                _document = document;
            }

            return(_document);
        }