1.RepositoryFramework(仓储接口:无外乎就是CRUD)
1.IAddRepository(添加接口)
using System; namespace Notify.Infrastructure.RepositoryFramework { /// <summary> /// IAddRepository{Add单条数据的接口} /// </summary> /// <typeparam name="T">T</typeparam> public interface IAddRepository<in T> : IDisposable { /// <summary> /// Add /// </summary> /// <param name="entity">entity</param> /// <returns>返回结果</returns> void Add(T entity); } }
2.IUpdateRepository(修改接接口)
using System; namespace Notify.Infrastructure.RepositoryFramework { /// <summary> /// IUpdateRepository{更新接口} /// </summary> /// <typeparam name="T">T</typeparam> public interface IUpdateRepository<in T> : IDisposable { /// <summary> /// Update /// </summary> /// <param name="entity">entity</param> /// <returns>返回结果</returns> void Update(T entity); } }
3.IQueryRepository(查询接口)
using System; namespace Notify.Infrastructure.RepositoryFramework { /// <summary> /// IQueryRepository{根据主键查询接口}. /// </summary> /// <typeparam name="TValue">实体</typeparam> public interface IQueryRepository<out TValue> : IDisposable { /// <summary> /// Query /// </summary> /// <param name="id">id</param> /// <returns>返回查询单条数据</returns> TValue Query(object id); } /// <summary> /// IQueryRepository{根据主键查询接口}. /// </summary> /// <typeparam name="TKey">Tkey</typeparam> /// <typeparam name="TValue">实体</typeparam> public interface IQueryRepository<in TKey,out TValue> : IDisposable { /// <summary> /// Query /// </summary> /// <param name="key">id</param> /// <returns>返回查询单条数据</returns> TValue Query(TKey key); } }
4.IRemoveRepository(删除接口)
using System; namespace Notify.Infrastructure.RepositoryFramework { /// <summary> /// IRepository{删除接口} /// </summary> /// <typeparam name="T">TKey</typeparam> public interface IRemoveRepository<in T> : IDisposable { /// <summary> /// Remove /// </summary> /// <param name="entity">T</param> /// <returns>返回结果</returns> void Remove(T entity); } }
5.IRepository(仓储接口 CRUD汇总)
using Notify.Infrastructure.DomainBase; namespace Notify.Infrastructure.RepositoryFramework { /// <summary> /// 仓储接口(CRUD) /// </summary> /// <typeparam name="TValue">实体</typeparam> public interface IRepository<TValue> : IAddRepository<TValue>, IRemoveRepository<TValue>, IUpdateRepository<TValue>, IQueryRepository<TValue> where TValue : IEntity { } /// <summary> /// 仓储接口(CRUD) /// </summary> /// <typeparam name="TKey">主键</typeparam> /// <typeparam name="TValue">实体</typeparam> public interface IRepository<in TKey, TValue> : IAddRepository<TValue>, IRemoveRepository<TValue>, IUpdateRepository<TValue>, IQueryRepository<TKey, TValue> where TValue : IEntity { } }