zoukankan      html  css  js  c++  java
  • 不成功的MVC Repository模式,记录下来,后面看看原因在哪里(三) IDevTypeRepository 及 DevTypeRepository

     1  public class DevTypeRepository:Repository<DevDevtypeMdl>,IDevTypeRepository
     2     {
     3 
     4         //在执行子类构造函数之前,先执行基类Repository<DevDevtypeMdl>的构造函数
     5         public DevTypeRepository(WBIDbContext m_dbContext)
     6             : base(m_dbContext)
     7         { }
     8 
     9         public DevDevtypeMdl FindByCd(string argDevCd)
    10         {
    11             return m_currentRepository.Find(u => u.devid == argDevCd);
    12         }
    13 
    14         public DevDevtypeMdl FindByName(string argDevName)
    15         {
    16             return m_currentRepository.Find(u => u.devdesc == argDevName);
    17         }
    18 
    19         public List<DevDevtypeMdl> FindPageList(int pageIndex, int pageSize, out int totalRecordCnt, 
    20             int order, DevDevtypeMdl condition)
    21         {
    22             IQueryable<DevDevtypeMdl> queryTable = null;
    23             global::System.Linq.Expressions.Expression<Func<DevDevtypeMdl, bool>> whereLamba = null;
    24 
    25             if (string.IsNullOrWhiteSpace(condition.devid) && string.IsNullOrWhiteSpace(condition.devdesc))
    26             {
    27                 whereLamba = m => true;
    28             }
    29             else if (!string.IsNullOrWhiteSpace(condition.devid) && !string.IsNullOrWhiteSpace(condition.devdesc))
    30             {
    31                 whereLamba = m => m.devid == condition.devid && m.devdesc == condition.devdesc;
    32             }
    33             else if (string.IsNullOrWhiteSpace(condition.devid))
    34             {
    35                 whereLamba = m => m.devdesc == condition.devdesc;
    36             }
    37             else
    38             {
    39                 whereLamba = m => m.devid == condition.devid;
    40             }
    41 
    42             switch (order)
    43             {
    44                 case 0:
    45                     queryTable = m_currentRepository
    46                         .FindPageList(pageIndex, pageSize, out totalRecordCnt, whereLamba, true, u => u.devid);
    47                     break;
    48                 case 1:
    49                     queryTable = m_currentRepository
    50                         .FindPageList(pageIndex, pageSize, out totalRecordCnt, whereLamba, true, u => u.devdesc);
    51                     break;
    52                 //case 2:
    53                 //    queryTable = m_currentRepository
    54                 //        .FindPageList(pageIndex, pageSize, out totalRecordCnt, u => true, true, u => u.GroupID);
    55                 //    break;
    56                 //case 3:
    57                 //    queryTable = m_currentRepository
    58                 //        .FindPageList(pageIndex, pageSize, out totalRecordCnt, u => true, true, u => u.CreateTime);
    59                 //    break;
    60                 //case 4:
    61                 //    queryTable = m_currentRepository
    62                 //        .FindPageList(pageIndex, pageSize, out totalRecordCnt, u => true, true, u => u.UpdateTime);
    63                 //    break;
    64                 default:
    65                     queryTable = m_currentRepository
    66                         .FindPageList(pageIndex, pageSize, out totalRecordCnt, whereLamba, true, u => u.devid);
    67                     break;
    68             }
    69 
    70 
    71             List<DevDevtypeMdl> lstUser = new List<DevDevtypeMdl>();
    72 
    73             if (queryTable != null)
    74             {
    75                 lstUser = queryTable.ToList();
    76             }
    77 
    78             return lstUser;
    79         }
    80 
    81     }
     1  public interface IDevTypeRepository:IRepository<DevDevtypeMdl>
     2     {
     3         DevDevtypeMdl FindByCd(string argUserCd);
     4 
     5         DevDevtypeMdl FindByName(string argUserName);
     6 
     7         //实体自己的特定逻辑--翻页
     8         List<DevDevtypeMdl> FindPageList(int pageIndex, int pageSize, out int totalRecordCnt, int order, DevDevtypeMdl condition);
     9 
    10     }
  • 相关阅读:
    ASCII、GBK、Unicode、UTF-8、ISO-8859-1等常见字符编码介绍
    HTTP协议简介
    关于无知的一点思考
    Java 8 新特性之lambda表达式
    Java 8 新特性之新的日期时间库
    【java】<Jsoup>获取网页中的图片
    【数据结构】二叉树
    【转载】Android中UI线程与后台线程交互设计的5种方法
    【数据结构】广义表
    【c语言】数据结构(约瑟夫生者死者游戏的问题)
  • 原文地址:https://www.cnblogs.com/minglilee2012/p/4043783.html
Copyright © 2011-2022 走看看