zoukankan      html  css  js  c++  java
  • 仓储类小议

    Repository.cs 为仓储提供公共方法的父类,用于总领整个领域驱动模型,用于对于NO业务限制所以操作,最简单的就是增删改查,基本就是集成到这个仓储类中,进行统一的解析和执行

    Business.cs为Bean类

    IBusinessRepository.cs为接口业务方法附加类

    BusinessRepositoryImpl.cs为业务方法的实现类

        /// <summary>
        /// Repository  For All Repository
        /// </summary>
        /// <typeparam name="T"></typeparam>
        public class Repository<T> where T : class
        {
            /// <summary>
            /// Find an instance with predicate
            /// </summary>
            /// <param name="predicate">predicate</param>
            /// <returns>An instance of class T</returns>
             T FindForSingle(Func<T, bool> predicate)
            {
                return FindAll().Where(predicate).FirstOrDefault();
            }

             /// <summary>
             /// Find matched instances with predicate
             /// </summary>
             /// <param name="predicate">predicate</param>
             /// <returns>An instance of class T</returns>
             IEnumerable<T> FindForMatch(Func<T, bool> predicate)
             {
                 return FindAll().Where(predicate);
             }

            /// <summary>
            /// Find all instances
            /// </summary>
            /// <returns></returns>
            IEnumerable<T> FindAll()
            {
                return new List<T>();
            }

            /// <summary>
            /// Save an instance
            /// </summary>
            /// <param name="instance"></param>
            void Save(T instance)
            {
               
            }

            /// <summary>
            /// Insert an instance
            /// </summary>
            /// <param name="instance"></param>
            void Insert(T instance)
            {
               
            }

            /// <summary>
            /// Update an instance
            /// </summary>
            /// <param name="instance"></param>
            void Update(T instance)
            {
               
            }
        }

        public class Business{}

        /// <summary>
        /// IBusinessRepository For Its Own
        /// </summary>
        public interface IBusinessRepository
        {
            /// <summary>
            /// Proccess for business
            /// </summary>
            void Proccess();
        }

        public class BusinessRepositoryImpl:Repository<Business>,IBusinessRepository
        {
            public void Proccess()
            {
               
            }
        }

  • 相关阅读:
    如何将一棵树转化成二叉树
    雪碧图的使用
    CSS简介,引入方式,文字和文本样式设置
    表格Table和表单元素
    html 中< col>标签和< colgroup>标签的区别
    Emmet的HTML语法(敲代码的快捷方式)
    抖音风格字体效果
    几种有效减小电脑系统盘使用量的方法
    ubuntu 机器名称修改方法
    Ubuntu 为基于X应用程序增加启动项的正确做法
  • 原文地址:https://www.cnblogs.com/otomii/p/1952782.html
Copyright © 2011-2022 走看看