/// <summary> /// Performs expands based on the list of strings. /// Also populates the ExpandTypeMap that controls lazy initialization and serialization. /// </summary> /// <param name="queryable"></param> /// <param name="expands"></param> /// <param name="request"></param> /// <returns></returns> protected IQueryable ApplyExpansions(IQueryable queryable, IList <string> expands, HttpRequestMessage request) { var expandMap = GetRequestProperty(request, EXPAND_MAP_KEY) as ExpandTypeMap; if (expandMap == null) { expandMap = new ExpandTypeMap(); } var session = GetRequestProperty(request, NH_SESSION_KEY) as ISession; if (queryable == null) { throw new Exception("Query cannot be null"); } var fetcher = new NHEagerFetch(session.SessionFactory); queryable = fetcher.ApplyExpansions(queryable, expands.ToArray(), expandMap); if (!request.Properties.ContainsKey(EXPAND_MAP_KEY)) { request.Properties.Add(EXPAND_MAP_KEY, expandMap); } return(queryable); }
/// <summary> /// Overrides the method in QueryHelper to perform the $expands in NHibernate. /// Also populates the ExpandTypeMap that controls lazy initialization and serialization. /// </summary> /// <param name="queryable"></param> /// <param name="expandsQueryString"></param> /// <returns></returns> public override IQueryable ApplyExpand(IQueryable queryable, string expandsQueryString) { if (string.IsNullOrWhiteSpace(expandsQueryString)) return queryable; var session = GetSession(queryable); var fetcher = new NHEagerFetch(session.SessionFactory); queryable = fetcher.ApplyExpansions(queryable, expandsQueryString, expandMap); return queryable; }
/// <summary> /// Performs expands based on the list of strings in queryable.GetIncludes(). /// Also populates the ExpandTypeMap that controls lazy initialization and serialization. /// </summary> /// <param name="queryable"></param> /// <returns></returns> public IQueryable ApplyExpand(IQueryableInclude queryable) { var expands = queryable.GetIncludes(); if (expands == null || expands.Count == 0) return queryable; var session = GetSession(queryable); var fetcher = new NHEagerFetch(session.SessionFactory); var expandedQueryable = fetcher.ApplyExpansions(queryable, expands.ToArray(), expandMap); return expandedQueryable; }
/// <summary> /// Overrides the method in QueryHelper to perform the $expands in NHibernate. /// Also populates the ExpandTypeMap that controls lazy initialization and serialization. /// </summary> /// <param name="queryable"></param> /// <param name="expandsQueryString"></param> /// <returns></returns> public override IQueryable ApplyExpand(IQueryable queryable, string expandsQueryString) { if (string.IsNullOrWhiteSpace(expandsQueryString)) { return(queryable); } var session = GetSession(queryable); var fetcher = new NHEagerFetch(session.SessionFactory); queryable = fetcher.ApplyExpansions(queryable, expandsQueryString, expandMap); return(queryable); }
/// <summary> /// Performs expands based on the list of strings in queryable.GetIncludes(). /// Also populates the ExpandTypeMap that controls lazy initialization and serialization. /// </summary> /// <param name="queryable"></param> /// <returns></returns> public IQueryable ApplyExpand(IQueryableInclude queryable) { var expands = queryable.GetIncludes(); if (expands == null || expands.Count == 0) { return(queryable); } var session = GetSession(queryable); var fetcher = new NHEagerFetch(session.SessionFactory); var expandedQueryable = fetcher.ApplyExpansions(queryable, expands.ToArray(), expandMap); return(expandedQueryable); }
/// <summary> /// Calls NHEagerFetch.ApplyExpansions /// </summary> /// <param name="queryable">The query to expand</param> /// <param name="expandsQueryString">value of the $expand query parameter</param> /// <param name="expandMap">Empty dictionary that will be populated with the names of the expanded properties for each type.</param> /// <returns></returns> protected IQueryable ApplyExpansions(IQueryable queryable, string expandsQueryString, ExpandTypeMap expandMap, ISessionFactory sessionFactory) { if (string.IsNullOrWhiteSpace(expandsQueryString)) { return(queryable); } string[] expandPaths = expandsQueryString.Split(',').Select(s => s.Trim()).ToArray(); if (!expandPaths.Any()) { throw new Exception("Expansion Paths cannot be null"); } if (queryable == null) { throw new Exception("Query cannot be null"); } var fetcher = new NHEagerFetch(sessionFactory); return(fetcher.ApplyExpansions(queryable, expandPaths, expandMap)); }
/// <summary> /// Calls NHEagerFetch.ApplyExpansions /// </summary> /// <param name="queryable">The query to expand</param> /// <param name="expandsQueryString">value of the $expand query parameter</param> /// <param name="expandMap">Empty dictionary that will be populated with the names of the expanded properties for each type.</param> /// <returns></returns> protected IQueryable ApplyExpansions(IQueryable queryable, string expandsQueryString, ExpandTypeMap expandMap, ISessionFactory sessionFactory) { if (string.IsNullOrWhiteSpace(expandsQueryString)) { return queryable; } string[] expandPaths = expandsQueryString.Split(',').Select(s => s.Trim()).ToArray(); if (!expandPaths.Any()) throw new Exception("Expansion Paths cannot be null"); if (queryable == null) throw new Exception("Query cannot be null"); var fetcher = new NHEagerFetch(sessionFactory); return fetcher.ApplyExpansions(queryable, expandPaths, expandMap); }
/// <summary> /// Performs expands based on the list of strings. /// Also populates the ExpandTypeMap that controls lazy initialization and serialization. /// </summary> /// <param name="queryable"></param> /// <param name="expands"></param> /// <param name="request"></param> /// <returns></returns> protected IQueryable ApplyExpansions(IQueryable queryable, IList<string> expands, HttpRequestMessage request) { var expandMap = GetRequestProperty(request, EXPAND_MAP_KEY) as ExpandTypeMap; if (expandMap == null) expandMap = new ExpandTypeMap(); var session = GetRequestProperty(request, NH_SESSION_KEY) as ISession; if (queryable == null) throw new Exception("Query cannot be null"); var fetcher = new NHEagerFetch(session.SessionFactory); queryable = fetcher.ApplyExpansions(queryable, expands.ToArray(), expandMap); if (!request.Properties.ContainsKey(EXPAND_MAP_KEY)) request.Properties.Add(EXPAND_MAP_KEY, expandMap); return queryable; }