/// <summary> /// Extends the reader by reading another set of records that are children of the previous results. /// </summary> /// <typeparam name="T1">The type of objects in the first set of results.</typeparam> /// <typeparam name="T2">The type of objects in the second set of results.</typeparam> /// <typeparam name="TId">The type of the ID value.</typeparam> /// <param name="previous">The previous reader.</param> /// <param name="recordReader">The mapping that defines the layout of the records in each row.</param> /// <param name="id">An optional function that extracts an ID from the object. Use when this row is a parent in a parent-child relationship.</param> /// <param name="into">A function that assigns the children to their parent.</param> /// <returns>A reader that reads a Results object with child records.</returns> public static ResultsReader <T1> ThenChildren <T1, T2, TId>( this ResultsReader <T1> previous, RecordReader <T2> recordReader, Func <T1, TId> id, Action <T1, List <T2> > into = null) { return(previous.ThenChildren(recordReader.GroupByAuto <T1, TId>(), id, into)); }
/// <summary> /// Extends the reader by reading another set of records that are children of a subobject of the previous results. /// </summary> /// <typeparam name="TRoot">The type of the root object that is returned.</typeparam> /// <typeparam name="TParent">The type of the parent object in the parent-child relationship.</typeparam> /// <typeparam name="TChild">The type of the child in the parent-child relationship.</typeparam> /// <typeparam name="TId">The type of the ID value.</typeparam> /// <param name="previous">The previous reader.</param> /// <param name="recordReader">The mapping that defines the layout of the records in each row.</param> /// <param name="parents">A function that selects the list of parents from the root object.</param> /// <param name="id">A function that selects the ID from a parent.</param> /// <param name="into">A function that assigns the children to their parent.</param> /// <returns>A reader that reads a Results objects with children.</returns> public static ResultsReader <TRoot> ThenChildren <TRoot, TParent, TChild, TId>( this ResultsReader <TRoot> previous, RecordReader <TChild> recordReader, Func <TRoot, IEnumerable <TParent> > parents, Func <TParent, TId> id, Action <TParent, List <TChild> > into = null) { return(previous.ThenChildren(recordReader.GroupByAuto <TParent, TId>(), parents, id, into)); }
public static ListReader <T1> ThenChildren <T1, T2>( this ListReader <T1> previous, RecordReader <T2> recordReader, Action <T1, List <T2> > into = null) { if (previous == null) { throw new ArgumentNullException("previous"); } if (recordReader == null) { throw new ArgumentNullException("recordReader"); } return(previous.ThenChildren(recordReader.GroupByAuto <T1, object>(), null, into)); }
public static ListReader <TRoot> ThenChildren <TRoot, TParent, TChild>( this ListReader <TRoot> previous, RecordReader <TChild> recordReader, Func <TRoot, IEnumerable <TParent> > parents, Action <TParent, List <TChild> > into = null) { if (previous == null) { throw new ArgumentNullException("previous"); } if (recordReader == null) { throw new ArgumentNullException("recordReader"); } return(previous.ThenChildren(recordReader.GroupByAuto <TParent, object>(), parents, null, into)); }
/// <summary> /// Extends the reader by reading another set of records that are children of the previous results. /// </summary> /// <typeparam name="T1">The type of objects in the first set of results.</typeparam> /// <typeparam name="T2">The type of objects in the second set of results.</typeparam> /// <typeparam name="TId">The type of the ID value.</typeparam> /// <param name="previous">The previous reader.</param> /// <param name="recordReader">The mapping that defines the layout of the records in each row.</param> /// <param name="id">An optional function that extracts an ID from the object. Use when this row is a parent in a parent-child relationship.</param> /// <param name="into">A function that assigns the children to their parent.</param> /// <returns>A reader that reads a Results object with child records.</returns> public static ResultsReader <T1> ThenChildren <T1, T2, TId>( this ResultsReader <T1> previous, RecordReader <T2> recordReader, Func <T1, TId> id, Action <T1, List <T2> > into = null) { if (previous == null) { throw new ArgumentNullException("previous"); } if (recordReader == null) { throw new ArgumentNullException("recordReader"); } return(previous.ThenChildren(recordReader.GroupByAuto <T1, TId>(), id, into)); }
public static SingleReader <TRoot> ThenChildren <TRoot, TParent, TChild, TId>( this SingleReader <TRoot> previous, RecordReader <TChild> recordReader, Func <TRoot, IEnumerable <TParent> > parents, Func <TParent, TId> id, Action <TParent, List <TChild> > into = null) { if (previous == null) { throw new ArgumentNullException("previous"); } if (recordReader == null) { throw new ArgumentNullException("recordReader"); } return(previous.AddChild(new Children <TRoot, TChild, TId>(recordReader.GroupByAuto <TParent, TId>(), new ChildMapper <TRoot, TParent, TChild, TId>(parents, id, into)))); }