/// <summary> /// Gets the multiple related CLR resources referenced by the "to-many" relationship. /// </summary> /// <typeparam name="TResource">Type of related CLR resource to get.</typeparam> /// <param name="relationship">The "to-many" relationship object that defines the /// multiple related CLR resources by json:api resource linkage.</param> /// <returns>Returns the LINQ-to-objects collection of related CLR resources /// referenced by the "to-many" relationship if they exist, empty collection otherwise.</returns> /// <exception cref="DocumentReadException">Is thrown if the relationship object /// passed is a "to-one" relationship instead of a "to-many" relationship.</exception> public static IEnumerable <TResource> GetRelatedResourceCollection <TResource>(this IDocumentReader documentReader, Relationship relationship) where TResource : class, IResource { Contract.Requires(documentReader != null); Contract.Requires(relationship != null); var clrRelatedResourceType = typeof(TResource); var clrRelatedResourceCollection = documentReader .GetRelatedResourceCollection(clrRelatedResourceType, relationship) .Cast <TResource>(); return(clrRelatedResourceCollection); }