/// <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> /// Recursively forces loading of each NHibernate proxy in the tree that matches an entry in the map. /// </summary> /// <param name="list">Top-level collection of objects</param> /// <param name="expandMap">Properties to initialize for each type</param> public static void InitializeList <T>(IEnumerable <T> list, params string[] expandPaths) { var expandMap = NHEagerFetch.MapExpansions(typeof(T), expandPaths); var map = expandMap.map; var depth = expandMap.maxDepth; foreach (var el in list) { InitializeWithCascade(el, map, depth); } }
/// <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); }