내 응용 프로그램에서는 TypeA, TypeB 및 TypeC와 같이 여러 유형의 회사에 액세스합니다. 그래서 회사 클래스가 있고 회사에서 상속 된 것은 TypeA, TypeB, TypeC입니다.컬렉션과 관련된 C# 상속 문제
그래서 사용자가 TypeA에서 검색을 수행 할보기가 있습니다. 검색 필드에는 Company의 필드와 TypeA의 필드가 포함됩니다. 그러나 TypeA 컬렉션이있는 경우 IEnumberable이라고 말하면 TypeA 클래스에서 필터링하기 전에 Company 클래스의 필드를 어떻게 필터링합니까?
편집
그래서이 내 의사 코드
나뿐만 아니라 숙박 시설 1 및 2에 필터링 할public abstract class Company
{
public string Property1 { get; set; }
public string Property2 { get; set; }
}
public class TypeA : Company
{
public string Property3 {get; set; }
}
public class TypeB : Company
{
public string Property4 {get; set; }
}
public abstract class SearchCompany
{
protected SearchCompany(string searchpProperty1, string searchProperty2)
{
// assign property code elided
}
public string SearchProperty1 { get; set; }
public string SearchProperty2 { get; set; }
}
public class SearchTypeA : SearchCompany
{
public SearchTypeA (string searchpProperty1, string searchProperty2, string searchProperty3)
: base (searchpProperty1, searchProperty2)
{
// assign property code elided
this.TypeAList = CacheObjects.TypeAList;
this.TypeAList = // this.TypeAList filtered by searchProperty3 depending on the wildcard
}
public string SearchProperty3 { get; set; }
public IList<TypeA> TypeAList { get; set; }
}
입니다.
이 아주 명확하지 않다. 당신이하려고하는 의사 코드를 게시 할 수 있습니까? – Oded
왜 다른 하나를 먼저해야합니까? – cjk
답을 모르겠지만 다른 사람들은 그가 상속 한 클래스에 필터를 적용하기 전에 기본 클래스의 필드를 기반으로 컬렉션을 필터링하는 방법을 찾고 있습니다. – Sayse