재사용 가능한 EF 모델 및 인터페이스 집합을 작성하려고합니다.EF 인터페이스 - 관련 형식으로 개체 가져 오기
public interface ICategorised {
int CategoryID { get; set; }
Category Category { get; set; }
}
을 그리고 여기에 카테고리 객체의 모습입니다 :
public class Category {
public int CategoryID { get; set; }
public string Title { get; set; }
public Type Type { get; set; } // Is 'Type' the wrong type for this?
public string Description { get; set; }
}
나는 확실히이의 원리처럼하지만 약간 방법에 난처한 해요 다음과 같이 하나는 이러한 인터페이스는 ICategorised
라고하고, 보이는됩니다 ICategorised
을 구현하는 객체의 Type을 가져오고 설정하는 것이 가장 좋습니다. ..
public class Car : ICategorised {
public int CarID { get; set; }
public string CarName { get; set; }
public int CategoryID { get; set; }
public Category Category { get; set; }
}
어떻게 든 Type==Car
Categories
를 조회 할 수 있습니다 : 내 최종 목표는 다음과 같은 객체를 생성 할 수있는 기능입니다.
몇 가지 유형이 발생할 것으로 예상하십니까? –
처음에는 부부였습니다. 내 계획은 이것, 비즈니스 로직, 뷰 등 내가 가능한 한 쉽게 재사용 할 수 있도록 함께 쓰고있다. – Phil