Skip to content

Commit 6988ba6

Browse files
committed
Fixes EntityFrameworkMaterializer bugs when materializing Decimal, etc.
1 parent e02071c commit 6988ba6

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

JSONAPI.EntityFramework/EntityFrameworkMaterializer.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Reflection;
1111
using System.Collections;
1212
using System.Data.Entity.Core;
13+
using JSONAPI.Extensions;
1314

1415
namespace JSONAPI.EntityFramework
1516
{
@@ -163,15 +164,7 @@ private bool IsMany(Type type)
163164

164165
public bool IsModel(Type objectType)
165166
{
166-
if (objectType.IsPrimitive
167-
|| typeof(System.Guid).IsAssignableFrom(objectType)
168-
|| typeof(System.DateTime).IsAssignableFrom(objectType)
169-
|| typeof(System.DateTimeOffset).IsAssignableFrom(objectType)
170-
|| typeof(System.Guid?).IsAssignableFrom(objectType)
171-
|| typeof(System.DateTime?).IsAssignableFrom(objectType)
172-
|| typeof(System.DateTimeOffset?).IsAssignableFrom(objectType)
173-
|| typeof(String).IsAssignableFrom(objectType)
174-
)
167+
if (objectType.CanWriteAsJsonApiAttribute())
175168
return false;
176169
else return true;
177170
}

JSONAPI/Extensions/TypeExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace JSONAPI.Extensions
44
{
5-
internal static class TypeExtensions
5+
public static class TypeExtensions
66
{
7-
internal static bool CanWriteAsJsonApiAttribute(this Type objectType)
7+
public static bool CanWriteAsJsonApiAttribute(this Type objectType)
88
{
99
if (objectType.IsGenericType && objectType.GetGenericTypeDefinition() == typeof (Nullable<>))
1010
objectType = objectType.GetGenericArguments()[0];

0 commit comments

Comments
 (0)