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