public static EmployeeTerritoryCollection ToDtoCollection(this EntityCollection <EmployeeTerritoryEntity> entities) { OnBeforeEntityCollectionToDtoCollection(entities); var seenObjects = new Hashtable(); var collection = new EmployeeTerritoryCollection(); foreach (var entity in entities) { collection.Add(entity.ToDto(seenObjects, new Hashtable())); } OnAfterEntityCollectionToDtoCollection(entities, collection); return(collection); }