Пример #1
0
        /// <summary>
        /// Opens a session for staging changes and then committing them atomically.
        /// </summary>
        /// <param name="factory">Factory delegate that creates new instances of <typeparamref name="T"/></param>
        /// <param name="documentMapper">Mapper that will convert documents to objects and vice versa.</param>
        /// <typeparam name="T">The type of object that will be mapped to <c cref="Document"/>.</typeparam>
        public ISession <T> OpenSession <T>(Func <T> factory, IDocumentMapper <T> documentMapper)
        {
            perFieldAnalyzer.Merge(documentMapper.Analyzer);

            return(new LuceneSession <T>(
                       documentMapper,
                       IndexWriter,
                       context,
                       CreateQueryable(factory, context, documentMapper)));
        }
Пример #2
0
        /// <summary>
        /// Opens a session for staging changes and then committing them atomically.
        /// </summary>
        /// <param name="lookup">Factory delegate that resolves instances of <typeparamref name="T"/></param>
        /// <param name="documentMapper">Mapper that will convert documents to objects and vice versa.</param>
        /// <param name="documentModificationDetector">Helper to determine when instances of <typeparamref name="T"/> are modified
        ///     and need to be updated in the index when the session is committed.
        /// </param>
        /// <typeparam name="T">The type of object that will be mapped to <c cref="Document"/>.</typeparam>
        public virtual ISession <T> OpenSession <T>(ObjectLookup <T> lookup, IDocumentMapper <T> documentMapper, IDocumentModificationDetector <T> documentModificationDetector)
        {
            perFieldAnalyzer.Merge(documentMapper.Analyzer);

            return(new LuceneSession <T>(
                       documentMapper,
                       documentModificationDetector,
                       IndexWriter,
                       context,
                       CreateQueryable(lookup, context, documentMapper)));
        }