diff --git a/src/Umbraco.Core/Mapping/MapperContext.cs b/src/Umbraco.Core/Mapping/MapperContext.cs
index b001300952..a7044a05b9 100644
--- a/src/Umbraco.Core/Mapping/MapperContext.cs
+++ b/src/Umbraco.Core/Mapping/MapperContext.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Linq;
namespace Umbraco.Core.Mapping
{
@@ -112,6 +113,18 @@ namespace Umbraco.Core.Mapping
}
*/
+ ///
+ /// Maps an enumerable of source objects to a new list of target objects.
+ ///
+ /// The type of the source objects.
+ /// The type of the target objects.
+ /// The source objects.
+ /// A list containing the target objects.
+ public List MapEnumerable(IEnumerable source)
+ {
+ return source.Select(Map).ToList();
+ }
+
#endregion
}
}
diff --git a/src/Umbraco.Core/Mapping/UmbracoMapper.cs b/src/Umbraco.Core/Mapping/UmbracoMapper.cs
index 2d7d9f97c4..0831edab4e 100644
--- a/src/Umbraco.Core/Mapping/UmbracoMapper.cs
+++ b/src/Umbraco.Core/Mapping/UmbracoMapper.cs
@@ -229,7 +229,7 @@ namespace Umbraco.Core.Mapping
if (ctor != null && map != null)
{
// register (for next time) and do it now (for this time)
- object NCtor(object s, MapperContext c) => MapEnumerable((IEnumerable) s, targetGenericArg, ctor, map, c);
+ object NCtor(object s, MapperContext c) => MapEnumerableInternal((IEnumerable) s, targetGenericArg, ctor, map, c);
DefineCtors(sourceType)[targetType] = NCtor;
DefineMaps(sourceType)[targetType] = Identity;
return (TTarget) NCtor(source, context);
@@ -241,7 +241,7 @@ namespace Umbraco.Core.Mapping
throw new InvalidOperationException($"Don't know how to map {sourceType.FullName} to {targetType.FullName}.");
}
- private TTarget MapEnumerable(IEnumerable source, Type targetGenericArg, Func