using System;
using System.Collections.Generic;
namespace Marr.Data
{
///
/// This utility class allows you to join two existing entity collections.
///
public class EntityMerger
{
///
/// Joines to existing entity collections.
///
/// The parent entity type.
/// The child entity type.
/// The parent entities.
/// The child entities
/// A predicate that defines the relationship between the parent and child entities. Returns true if they are related.
/// An action that adds a related child to the parent.
public static void Merge(IEnumerable parentList, IEnumerable childList, Func relationship, Action mergeAction)
{
foreach (TParent parent in parentList)
{
foreach (TChild child in childList)
{
if (relationship(parent, child))
{
mergeAction(parent, child);
}
}
}
}
}
}