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?
As asawyer said, it is only meaningful to override methods and properties that you actually can override, i.e. virtual
and abstract
members.
To "override" non-virtual or non-abstract members, you have to use the new
modifier. E.g.
public new DbDataReader ExecuteReader()
This has the usual drawbacks, as described in the MSDN reference article.
精彩评论