实现 DbCommand 并没有实现所有抽象类
我尝试实现抽象 DbCommand 类(如 OdbcCommand、OleDbCommand,...),但我不明白的是为什么当我写:
internal sealed class SybaseCommand : DbCommand, IDisposable
并且我要求 VS2008 实现所有抽象类时,它不会自动生成每个方法/属性的所有重写存根。
这是 MSDN DbCommand 类:http://msdn。 microsoft.com/en-us/library/system.data.common.dbcommand.aspx
它不会为我生成“Connection”、“CanRaiseEvents”/...属性的存根,而不是存根对于 ExecuteReader()。
你能告诉我为什么吗?我错过了什么吗?
感谢您的帮助:)
[编辑]
对于 ExecuteReader() 方法,有 3 个方法
public DbDataReader ExecuteReader()
public DbDataReader ExecuteReader(CommandBehavior behavior)
protected abstract DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
我可以假设这两个公共方法都只调用受保护的方法吗?
I try to implement the abstract DbCommand class (like OdbcCommand, OleDbCommand, ...) but a thing that I don't understand is why when I write :
internal sealed class SybaseCommand : DbCommand, IDisposable
and I ask VS2008 to implement all the abstract class, it doesn't generate automatically all override stub for each method / property.
Here is the MSDN DbCommand class : http://msdn.microsoft.com/en-us/library/system.data.common.dbcommand.aspx
It doesn't generate me the stub for the property for "Connection", "CanRaiseEvents" / ... and not the stub for ExecuteReader().
Can you tell me why? I've missed something?
Thanks for help :)
[EDIT]
In case of the ExecuteReader() method, there are 3 methods
public DbDataReader ExecuteReader()
public DbDataReader ExecuteReader(CommandBehavior behavior)
protected abstract DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
Can I suppose that both public methods are only calling the protected one?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 asawyer 所说,只有重写你实际上可以重写的方法和属性才有意义,即
虚拟
和抽象
成员。要“覆盖”非虚拟或非抽象成员,您必须使用
新
修饰符。例如,这具有常见的缺点,如 MSDN 参考文章。
As asawyer said, it is only meaningful to override methods and properties that you actually can override, i.e.
virtual
andabstract
members.To "override" non-virtual or non-abstract members, you have to use the
new
modifier. E.g.This has the usual drawbacks, as described in the MSDN reference article.