コード例 #1
0
        /// <summary>
        /// This Prefetch call is a simpler API for when you are not interested in tweaking the Query
        /// </summary>
        /// <param name="maps">The Path to the data</param>
        public void Prefetch(params esPrefetchMap[] maps)
        {
            if (maps != null)
            {
                if (prefetchMaps == null)
                {
                    prefetchMaps = new List <esPrefetchMap>();
                }

                esPrefetchParameters data = new esPrefetchParameters();

                // Create the query, we do so in reverse order
                for (int i = maps.Length - 1; i >= 0; i--)
                {
                    esPrefetchDelegate prefetchDelegate = maps[i].PrefetchDelegate;
                    prefetchDelegate(data);
                }

                // The path is the next to the last PropertyName
                string path = string.Empty;
                if (maps.Length > 1)
                {
                    path = maps[maps.Length - 2].PropertyName;
                }

                esPrefetchMap rootMap = maps[maps.Length - 1];
                rootMap.Query = data.Root;
                rootMap.Path  = path;
                prefetchMaps.Add(rootMap);

                rootMap.Query.Select(rootMap.Query);
            }
        }
コード例 #2
0
        /// <summary>
        /// This Prefetch allows you to fill in the Select() statement for the query to control what columns are brought back
        /// </summary>
        /// <typeparam name="T">The Type of the esDynamicQuery returned</typeparam>
        /// <param name="provideSelect">If true then you must fill in the Query.Select() clause</param>
        /// <param name="maps">The Path to the data</param>
        /// <returns>The esDynamicQuery for the Type of query you intend to load</returns>
        public T Prefetch <T>(bool provideSelect, params esPrefetchMap[] maps) where T : esDynamicQuery
        {
            if (maps != null)
            {
                if (prefetchMaps == null)
                {
                    prefetchMaps = new List <esPrefetchMap>();
                }

                esPrefetchParameters data = new esPrefetchParameters();

                // Create the query, we do so in reverse order
                for (int i = maps.Length - 1; i >= 0; i--)
                {
                    esPrefetchDelegate prefetchDelegate = maps[i].PrefetchDelegate;
                    prefetchDelegate(data);
                }

                // The path is the next to the last PropertyName
                string path = string.Empty;
                if (maps.Length > 1)
                {
                    path = maps[maps.Length - 2].PropertyName;
                }

                esPrefetchMap rootMap = maps[maps.Length - 1];
                rootMap.Query = data.Root;
                rootMap.Path  = path;
                prefetchMaps.Add(rootMap);

                if (provideSelect)
                {
                    rootMap.Query.Select(rootMap.Query);
                }

                return((T)data.Root);
            }

            return(null);
        }