我有以下界面:
public interface IInitializable
{
void Initialize ();
}
public interface IPersistXmlElementTo
{
XmlElement ToXmlElement (XmlDocument document);
}
public interface IPersistXmlElement<T>:
IPersistXmlElementTo,
IInitializable
{
T FromXmlElement (XmlElement element);
}
public interface IPersistXmlDocumentTo:
IPersistXmlElementTo
{
XmlDocument ToXmlDocument ();
}
public interface IPersistXmlDocument<T>:
IPersistXmlDocumentTo,
IPersistXmlElement<T>,
IInitializable
{
T FromXmlDocument (XmlDocument document);
}
public interface ICloneable<T>
where T: ICloneable<T>
{
T Clone ();
}
public interface ICopyable<T>:
IInitializable,
ICloneable<T>
where T: ICopyable<T>
{
T CopyFrom (T source);
T CopyTo (T destination);
}
public interface IEntity
{
long Id { get; set; }
byte [] TimeStamp { get; set; }
DateTime DateTimeCreated { get; set; }
DateTime DateTimeModified { get; set; }
}
目前,所有实体类都从IEntity
继承。我现在希望IEntity继承上面的接口。这意味着将IEntity转换为通用接口。类似的东西:
public interface IEntity<T>:
IPersistXmlDocument<T>,
IPersistXmlElement<T>,
ICloneable<T>,
ICopyable<T>,
IInitializable
where T: IEntity<T>
在从类继承时我遇到了EF问题,但到目前为止接口似乎工作正常。有什么值得注意的吗? EF中的任何特殊配置都需要从Entity: IEntity
切换到Entity: IEntity<Entity>
?
答案 0 :(得分:0)
事实证明,通用接口对EF无任何影响。