-
Notifications
You must be signed in to change notification settings - Fork 13
Entities
Furkan Güngör edited this page Nov 28, 2021
·
1 revision
It supports all entities of EasyRepository
class type. However, EasyRepository
includes a base entity to facilitate operations.
With the EasyBaseEntity
class;
- PrimaryKey
- CreationDate
- DeletionDate
- IsDeleted
- ModificationDate includes fields.
If you create your models with EasyBaseEntity
, the above information is automatically set in Create, Update and Delete operations. For entities derived with EasyBaseEntity
, the SoftDelete
feature is additionally available.
Do not worry. To use the EasyRepository
library, its models do not have to derive from the EasyBaseEntity
class. EasyRepository
works seamlessly for your own assets as well.
/// <summary>
/// This abstraction implemented base properties for entities
/// </summary>
/// <typeparam name="TPrimaryKey">
/// Primary Key type of the entity
/// </typeparam>
public abstract class EasyBaseEntity<TPrimaryKey> : IEasyEntity<TPrimaryKey>, IEasyCreateDateEntity, IEasyUpdateDateEntity, IEasySoftDeleteEntity
{
/// <summary>
/// Creation Date <see cref="{DateTime}"/>
/// </summary>
public virtual DateTime CreationDate { get; set; }
/// <summary>
/// Primary Key <see cref="{TPrimaryKey}"/>
/// </summary>
public virtual TPrimaryKey Id { get; set; }
/// <summary>
/// Modification Date <see cref="{DateTime}"/>
/// </summary>
public virtual DateTime? ModificationDate { get; set; }
/// <summary>
/// Deletion Date <see cref="{DateTime}"/>
/// </summary>
public virtual DateTime? DeletionDate { get; set; }
/// <summary>
/// Is Deleted <see cref="{Boolean}"/>
/// </summary>
public virtual bool IsDeleted { get; set; }
}
public class Author : EasyBaseEntity<Guid>
{
public string Name { get; set; }
public string Surname { get; set; }
public virtual ICollection<Book> Books { get; set; }
}
public class Book : EasyBaseEntity<Guid>
{
public string Title { get; set; }
public Guid AuthorId { get; set; }
public int TotalPage { get; set; }
public virtual Author Author { get; set; }
}
Welcome to the EasyRepository.EFCore
wiki!
Topics:
-
Getting Started
-
Implementations
-
Specification
-
Ardalis.Specification & EasyRepository.EFCore