Files
SteamTools/System.Common.CoreLib/Application/Repositories/IGetPrimaryKey.cs
T
2021-02-20 16:45:44 +08:00

18 lines
589 B
C#

using System.Application.Entities;
namespace System.Application.Repositories
{
public interface IGetPrimaryKey<TEntity> where TEntity : class
{
object GetPrimaryKey(TEntity entity);
}
public interface IGetPrimaryKey<TEntity, TPrimaryKey> : IGetPrimaryKey<TEntity>
where TEntity : class, IEntity<TPrimaryKey>
where TPrimaryKey : IEquatable<TPrimaryKey>
{
public new TPrimaryKey GetPrimaryKey(TEntity entity) => DefaultGetPrimaryKey(entity);
protected static TPrimaryKey DefaultGetPrimaryKey(TEntity entity) => entity.Id;
}
}