/// <summary> /// Specifies the related objects to include in the query results. /// </summary> /// <param name="path">The dot-separated list of related objects to return in the query results.</param> /// <returns>The current instance.</returns> public QueryOptions <T> Fetch([NotNull] string path) { Guard.NotEmpty(path, nameof(path)); _fetchStrategy = _fetchStrategy ?? new FetchQueryStrategy <T>(); _fetchStrategy.Fetch(path); return(this); }
/// <summary> /// Includes the fetch strategy which defines the child objects that should be retrieved when loading the entity and combines it with the current property pahts collection. /// </summary> /// <param name="fetchStrategy">Defines the child objects that should be retrieved when loading the entity.</param> /// <returns>The current instance.</returns> public QueryOptions <T> Include([NotNull] IFetchQueryStrategy <T> fetchStrategy) { Guard.NotNull(fetchStrategy, nameof(fetchStrategy)); var paths = _fetchStrategy != null ? ((IFetchQueryStrategy <T>)_fetchStrategy).PropertyPaths : new List <string>(); var mergedPaths = paths.Union(fetchStrategy.PropertyPaths).ToList(); _fetchStrategy = _fetchStrategy ?? new FetchQueryStrategy <T>(); mergedPaths.ForEach(path => _fetchStrategy.Fetch(path)); return(this); }