【问题标题】:C# Data Access GetAll() methods with many parameters具有许多参数的 C# 数据访问 GetAll() 方法
【发布时间】:2011-06-07 00:17:06
【问题描述】:

在数据访问层有如下方法是很常见的:

    Tuple<int, IList<Media>> GetAllWithFilter(int? page, string folderName, string title, string fileName, string author, string keywordTitle, int type, int fileType, int rowsPerPage, Guid keywordId, string sortField = null, string sortDir = null);

每次添加新属性时,它都会变得越来越混乱

保持这些方法的可读性和可维护性的良好做法是什么?

谢谢

【问题讨论】:

    标签: c# .net nhibernate repository data-access-layer


    【解决方案1】:

    为什么不创建一个包含所有过滤器属性的对象并将其传递出去?

    【讨论】:

      【解决方案2】:

      我认为这个会有所帮助。 Query pattern

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-04-08
        • 2019-09-15
        • 1970-01-01
        • 2012-11-25
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多