예제 #1
0
        public IQueryable <T> Query <T>(ILoadingStrategy <T> loadingStrategy = null, StaleResultsMode staleResults = StaleResultsMode.AllowStaleResultsMode)
        {
            var query = Session.Query <T>();

            query = ApplyLoadingStrategyToQuery(query, loadingStrategy);
            query = ApplyNonStaleResultsStrategy(query, staleResults);
            return(query);
        }
예제 #2
0
 public IQueryable <T> Query <T>(ILoadingStrategy <T> loadingStrategy = null, StaleResultsMode staleResults = StaleResultsMode.AllowStaleResultsMode)
 {
     return(_outsideSession.Query(loadingStrategy, staleResults));
 }
예제 #3
0
 public T GetById <T>(ValueType id, ILoadingStrategy <T> loadingStrategy = null)
 {
     return(_outsideSession.GetById(id, loadingStrategy));
 }
예제 #4
0
 public T[] GetByIds <T>(IEnumerable <string> ids, ILoadingStrategy <T> loadingStrategy = null)
 {
     return(_outsideSession.GetByIds <T>(ids, loadingStrategy));
 }
예제 #5
0
        public T GetById <T>(ValueType id, ILoadingStrategy <T> loadingStrategy = null)
        {
            var loader = ApplyLoadingStrategyToSession(Session, loadingStrategy);

            return(loader == null?Session.Load <T>(id) : loader.Load(id));
        }
예제 #6
0
        public T[] GetByIds <T>(IEnumerable <string> ids, ILoadingStrategy <T> loadingStrategy = null)
        {
            var loader = ApplyLoadingStrategyToSession(Session, loadingStrategy);

            return(loader == null?Session.Load <T>(ids) : loader.Load(ids.ToArray()));
        }
예제 #7
0
        private static IRavenQueryable <T> ApplyLoadingStrategyToQuery <T>(IRavenQueryable <T> query, ILoadingStrategy <T> strategy)
        {
            var loadingStrategy = (LoadingStrategy <T>)strategy;

            if (loadingStrategy == null || loadingStrategy.IsEmpty)
            {
                return(query);
            }

            return(query.Customize(x =>
            {
                var property = loadingStrategy.Dequeue();
                x.Include(property);
                while (!loadingStrategy.IsEmpty)
                {
                    property = loadingStrategy.Dequeue();
                    x.Include(property);
                }
            }));
        }
예제 #8
0
        private static ILoaderWithInclude <T> ApplyLoadingStrategyToSession <T>(IDocumentSession session, ILoadingStrategy <T> strategy)
        {
            var loadingStrategy = (LoadingStrategy <T>)strategy;

            if (loadingStrategy == null || loadingStrategy.IsEmpty)
            {
                return(null);
            }

            var property          = loadingStrategy.Dequeue();
            var loaderWithInclude = session.Include(property);

            while (!loadingStrategy.IsEmpty)
            {
                property          = loadingStrategy.Dequeue();
                loaderWithInclude = session.Include(property);
            }

            return(loaderWithInclude);
        }