diff --git a/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs b/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs
index 958398e0c5..9542383983 100644
--- a/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs
+++ b/framework/src/Volo.Abp.Core/System/AbpObjectExtensions.cs
@@ -2,6 +2,7 @@
using System.ComponentModel;
using System.Globalization;
using System.Linq;
+using System.Reflection;
namespace System
{
@@ -105,5 +106,36 @@ namespace System
return obj;
}
+
+ ///
+ /// Resets all fields of a given object to their default values.
+ ///
+ /// Type of the object
+ /// An object
+ /// Alternative custom method to reset the values.
+ /// Returns the original object.
+ public static T ResetState(this T obj, Action customReset = null)
+ {
+ if (customReset != null)
+ {
+ customReset(obj);
+ }
+ else
+ {
+ var properties = typeof(T).GetProperties();
+
+ foreach (var property in properties)
+ {
+ if (!property.CanWrite)
+ {
+ continue;
+ }
+
+ property.SetValue(obj, null);
+ }
+ }
+
+ return obj;
+ }
}
}