Skip to content

Commit e523a3e

Browse files
author
Bart Koelman
committed
Collections: type widening
1 parent 397e43a commit e523a3e

File tree

3 files changed

+3
-13
lines changed

3 files changed

+3
-13
lines changed

src/JsonApiDotNetCore/Data/DefaultResourceRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private void LoadInverseRelationships(object trackedRelationshipValue, Relations
142142
}
143143
else if (relationshipAttr is HasManyAttribute hasManyAttr && !(relationshipAttr is HasManyThroughAttribute))
144144
{
145-
foreach (IIdentifiable relationshipValue in (IList)trackedRelationshipValue)
145+
foreach (IIdentifiable relationshipValue in (IEnumerable)trackedRelationshipValue)
146146
_context.Entry(relationshipValue).Reference(hasManyAttr.InverseNavigation).Load();
147147
}
148148
}

src/JsonApiDotNetCore/Hooks/Traversal/RelationshipProxy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public object GetValue(IIdentifiable entity)
6262
return throughAttr.ThroughProperty.GetValue(entity);
6363
}
6464
var collection = new List<IIdentifiable>();
65-
var joinEntities = (IList)throughAttr.ThroughProperty.GetValue(entity);
65+
var joinEntities = (IEnumerable)throughAttr.ThroughProperty.GetValue(entity);
6666
if (joinEntities == null) return null;
6767

6868
foreach (var joinEntity in joinEntities)

src/JsonApiDotNetCore/Internal/TypeHelper.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal static class TypeHelper
1313
{
1414
private static bool IsNullable(Type type)
1515
{
16-
return (!type.IsValueType || Nullable.GetUnderlyingType(type) != null);
16+
return !type.IsValueType || Nullable.GetUnderlyingType(type) != null;
1717
}
1818

1919
public static object ConvertType(object value, Type type)
@@ -205,16 +205,6 @@ public static IEnumerable CreateHashSetFor(Type type, object elements = null)
205205
return (IEnumerable)CreateInstanceOfOpenType(typeof(HashSet<>), type, elements ?? new object());
206206
}
207207

208-
/// <summary>
209-
/// Gets the generic argument T of List{T}
210-
/// </summary>
211-
/// <returns>The type of the list</returns>
212-
/// <param name="list">The list to be inspected</param>
213-
public static Type GetListInnerType(IEnumerable list)
214-
{
215-
return list.GetType().GetGenericArguments()[0];
216-
}
217-
218208
/// <summary>
219209
/// Gets the type (Guid or int) of the Id of a type that implements IIdentifiable
220210
/// </summary>

0 commit comments

Comments
 (0)