File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ namespace MADE.Data.EFCore
55 /// <summary>
66 /// Defines a base definition for an entity.
77 /// </summary>
8- public abstract class EntityBase
8+ public abstract class EntityBase : IEntityBase
99 {
1010 /// <summary>
1111 /// Gets or sets the identifier of the entity.
Original file line number Diff line number Diff line change @@ -60,14 +60,14 @@ public static void SetEntityDates(this DbContext context)
6060 IEnumerable < EntityEntry > entries = context . ChangeTracker
6161 . Entries ( )
6262 . Where (
63- entry => entry . Entity is EntityBase &&
63+ entry => entry . Entity is IEntityBase &&
6464 ( entry . State == EntityState . Added || entry . State == EntityState . Modified ) ) ;
6565
6666 DateTime now = DateTime . UtcNow ;
6767
6868 foreach ( EntityEntry entry in entries )
6969 {
70- var entity = ( EntityBase ) entry . Entity ;
70+ var entity = ( IEntityBase ) entry . Entity ;
7171 entity . UpdatedDate = now ;
7272
7373 if ( entry . State == EntityState . Added && entity . CreatedDate == DateTime . MinValue )
Original file line number Diff line number Diff line change 1+ namespace MADE . Data . EFCore
2+ {
3+ using System ;
4+
5+ /// <summary>
6+ /// Defines a base definition for an entity.
7+ /// </summary>
8+ public interface IEntityBase
9+ {
10+ /// <summary>
11+ /// Gets or sets the identifier of the entity.
12+ /// </summary>
13+ Guid Id { get ; set ; }
14+
15+ /// <summary>
16+ /// Gets or sets the date of the entity's creation.
17+ /// </summary>
18+ DateTime CreatedDate { get ; set ; }
19+
20+ /// <summary>
21+ /// Gets or sets the date of the entity's last update.
22+ /// </summary>
23+ DateTime ? UpdatedDate { get ; set ; }
24+
25+ }
26+ }
You can’t perform that action at this time.
0 commit comments