Files
Umbraco-CMS/src/Umbraco.Core/Models/EntityExtensions.cs

24 lines
704 B
C#
Raw Normal View History

2017-11-15 08:53:20 +01:00
using Umbraco.Core.Models.EntityBase;
namespace Umbraco.Core.Models
{
public static class EntityExtensions
{
/// <summary>
/// Returns true if this entity has just been created and persisted to the data store
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
/// <remarks>
/// This is useful when handling events to determine if an entity is a brand new entity or was
/// already existing.
/// </remarks>
public static bool IsNewEntity(this IEntity entity)
{
2017-11-15 08:53:20 +01:00
var dirty = (IRememberBeingDirty) entity;
return dirty.WasPropertyDirty("Id");
}
}
2017-07-20 11:21:28 +02:00
}