Browse Source
Make `IsValueObject` check customizable.
pull/16204/head
maliming
3 years ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
2 changed files with
10 additions and
3 deletions
-
framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs
-
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/EntityHistory/EntityHistoryHelper.cs
|
|
|
@ -123,10 +123,17 @@ public static class EntityHelper |
|
|
|
return typeof(IEntity).IsAssignableFrom(type); |
|
|
|
} |
|
|
|
|
|
|
|
public static Func<Type, bool> IsValueObjectPredicate = type => typeof(ValueObject).IsAssignableFrom(type); |
|
|
|
|
|
|
|
public static bool IsValueObject([NotNull] Type type) |
|
|
|
{ |
|
|
|
Check.NotNull(type, nameof(type)); |
|
|
|
return typeof(ValueObject).IsAssignableFrom(type); |
|
|
|
return IsValueObjectPredicate(type); |
|
|
|
} |
|
|
|
|
|
|
|
public static bool IsValueObject(object obj) |
|
|
|
{ |
|
|
|
return obj != null && IsValueObject(obj.GetType()); |
|
|
|
} |
|
|
|
|
|
|
|
public static void CheckEntity([NotNull] Type type) |
|
|
|
|
|
|
|
@ -93,7 +93,7 @@ public class EntityHistoryHelper : IEntityHistoryHelper, ITransientDependency |
|
|
|
} |
|
|
|
|
|
|
|
var entityId = GetEntityId(entity); |
|
|
|
if (entityId == null && changeType != EntityChangeType.Created && !(entity is ValueObject)) |
|
|
|
if (entityId == null && changeType != EntityChangeType.Created && !EntityHelper.IsValueObject(entity)) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
@ -151,7 +151,7 @@ public class EntityHistoryHelper : IEntityHistoryHelper, ITransientDependency |
|
|
|
return keys.JoinAsString(","); |
|
|
|
} |
|
|
|
|
|
|
|
if (entityAsObj is ValueObject) |
|
|
|
if (EntityHelper.IsValueObject(entityAsObj)) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
|