하위 범주가있는 자체 참조 엔터티 범주가 있습니다. 그것은 아주 잘 작동합니다.Entity Framework 데이터베이스 첫째, 자체 참조 엔터티 계층에 대한 인터페이스
이제는 JsTree 도우미를 구현하고 싶지만 유사한 구조 (Category는 두 프로젝트에서 100 % 비슷한 엔티티)를 사용하는 다른 프로젝트가 있기 때문에 클래스 라이브러리에 도우미를 구현하고이를 만들고 싶습니다. 둘 다 사용할 수 있습니다.
[EdmEntityTypeAttribute(NamespaceName="MyModel", Name="Category")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class Category : EntityObject
{
/// <summary>
/// No Metadata Documentation available.
/// </summary>
[XmlIgnoreAttribute()]
[SoapIgnoreAttribute()]
[DataMemberAttribute()]
[EdmRelationshipNavigationPropertyAttribute("MyModel", "FK_Categories_Categories", "Categories1")]
public EntityCollection<Category> Subcategories
{
get
{
return ((IEntityWithRelationships)this).RelationshipManager.GetRelatedCollection<Category>("WebDirectoryModel.FK_Categories_Categories", "Categories1");
}
set
{
if ((value != null))
{
((IEntityWithRelationships)this).RelationshipManager.InitializeRelatedCollection<Category>("MyModel.FK_Categories_Categories", "Categories1", value);
}
}
}
}
이 내가 쓴 인터페이스입니다 :
public interface ICategory
{
System.Int32 CategoryId { get; set; }
System.String DefaultName { get; set; }
EntityCollection<ICategory> Subcategories { get; set; }
}
가 그리고 내가 범주 구현 ICategory 또 다른 부분 클래스를 추가
이
는 엔티티 프레임 워크에 의해 생성 된 코드, 여기에 어떤 변화입니다 :public partial class Category : ICategory
{
}
문제는 내가 다음과 같은 컴파일 전자 rror :
Error 6 'MyProject.EntityFramework.Models.Category' does not implement interface member 'ICategory.Subcategories'. 'MyProject.EntityFramework.Models.Category.Subcategories' cannot implement 'ICategory.Subcategories' because it does not have the matching return type of 'System.Data.Objects.DataClasses.EntityCollection < ICategory > '.
이 문제를 해결하는 방법에 대한 아이디어가 있으십니까? 내가 도대체 뭘 잘못하고있는 겁니까? 카테고리가 ICategory를 구현하므로 ICategory의 하위 카테고리 (ICategory 컬렉션)가 일치해야합니까?
저는 EF 4.4를 사용하고 있습니다. 그러나 문제는 그와 관련이 없다고 생각합니다. 미리 감사드립니다.