• EsayUI + MVC + ADO.NET(仓储基础接口)


      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
        {
        }
    }

       上篇--项目架构

       下篇--工作单元

  • 相关阅读:
    使用HSQLDB 客户端(jvm自带数据库使用技巧)
    PageHelper分页
    使用exe4j打包Java程序
    有图形界面的聊天程序
    同时收发消息
    服务端和客户端互聊
    使用Scanner
    收发字符串
    收发数字
    建立连接
  • 原文地址:https://www.cnblogs.com/liuxiaoji/p/4997049.html
Copyright © 2020-2023  润新知