public static TQuery ChildQuery <TQuery>(this TQuery query, IRepositoryQuery childQuery) where TQuery : IRepositoryQuery { if (childQuery == null) { throw new ArgumentNullException(nameof(childQuery)); } if (childQuery.GetDocumentType() == typeof(object)) { throw new ArgumentException("DocumentType must be set on child queries", nameof(childQuery)); } return(query.AddCollectionOptionValue(ChildQueriesKey, childQuery)); }