public Interface IEntity
Property ID() as Integer
end Interface
我想我所有的EF對象來實現對有主鍵的這個接口。
這可能嗎?
public Interface IEntity
Property ID() as Integer
end Interface
我想我所有的EF對象來實現對有主鍵的這個接口。
這可能嗎?
這似乎很容易在CSHARP但在VB做,你必須明確聲明其性能/功能/潛艇是實現該接口:
public Property Id() as Integer Implements IEntity.Id
不幸的是,我不得不撕裂了設計文件並修改生成的屬性。我最終一起擺脫了生成的文件,現在將我的模型保存在具有所有Attribute映射的單獨類中。
這些類是部分的,所以它應該很容易做到。
是的,你可以。設計器生成的類聲明爲部分。在單獨的源文件中,您可以爲這些類聲明其他方法。您還可以聲明已生成的類已實現的特定接口。
/* This is the interface that you want to have implemented. */
public interface ISomething
{
void DoSomething();
}
/* This would be part of the generated class */
partial class PartialClass
{
public void DoSomething()
{
}
}
/* This would be your own extension */
partial class PartialClass : ISomething
{
}
注意由於缺少Attribute Mapping的文檔,我在EF Framework上切換到Linq – Kelly 2009-02-08 20:20:46