diff --git a/dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs b/dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs index c05addf7d..81af90fb7 100644 --- a/dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs +++ b/dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs @@ -2663,6 +2663,8 @@ static public object ConvertToInternal(Type to, Object i) { o = convertFuncts[to].ConvertToList(i); } + else if (to.IsInstanceOfType(i)) + o = i; else if (ienumerableType != null) { IList lst = (IList)Activator.CreateInstance((typeof(List<>).MakeGenericType(ienumerableType))); @@ -2670,8 +2672,6 @@ static public object ConvertToInternal(Type to, Object i) lst.Add(item); o = lst; } - else if (to.IsInstanceOfType(i)) - o = i; else { IList l = (IList)Activator.CreateInstance(to); @@ -2684,10 +2684,12 @@ static public object ConvertToInternal(Type to, Object i) static Type GetEnumerableType(Type type) { -#if !NETCORE - if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>)) - return type.GetGenericArguments()[0]; -#endif + if (type.IsGenericType) + { + return type.GetInterfaces() + .FirstOrDefault(t => t.IsGenericType && t.GetGenericTypeDefinition() == typeof(IEnumerable<>)) + ?.GetGenericArguments()[0]; + } return null; }