C# 使用存储库模式查询字符串字段的不同列表的正确方法

C# 使用存储库模式查询字符串字段的不同列表的正确方法,c#,design-patterns,repository-pattern,C#,Design Patterns,Repository Pattern,我想选择一个字符串字段的不同列表,以便用户能够选择一个并以这种方式过滤实体 以正确的方式使用该模式的最佳实践是什么 例如,我有一门课: public class A { public int id { set; get; } public int a1 { set; get; } public string a2 { set; get; } public int a3 { set; get; } } 这个接口正确吗,或者我应该用其他方法来实现 public in

我想选择一个字符串字段的不同列表,以便用户能够选择一个并以这种方式过滤实体

以正确的方式使用该模式的最佳实践是什么

例如,我有一门课:

public class A
{
    public int id { set; get; }
    public int a1 { set; get; }
    public string a2 { set; get; }
    public int a3 { set; get; }
}
这个接口正确吗,或者我应该用其他方法来实现

public interface IARepository
{
    A Select(int id);
    IList<A> SelectAll();
    void Delete(int id);
    void Update(A selection);
    void Insert(A selection);

    IList<String> SelectDistinctA2();   // <-- are these 2 lines correct?
    IList<A> SelectAllByA2(string a2);  // <--
}

我想到了另一种可能的方法:

public class A
{
    public int id { set; get; }
    public int a1 { set; get; }
    public A2 a2 { set; get; }
    public int a3 { set; get; }
}

public class A2
{
    public string text { set; get; }
}

public interface IARepository
{
    A Select(int id);
    IList<A> SelectAll();
    void Delete(int id);
    void Update(A selection);
    void Insert(A selection);

    IList<A> SelectAllByA2(A2 a2);  // or IList<A> SelectAllByA2(string a2Text);  
}

public interface IA2Repository
{
    IList<A2> SelectDistinctA2();          
}