当我使用这个时,我得到以下异常
Parameter discovery is not supported for connections using GenericDatabase. You must specify the parameters explicitly, or configure the connection to use a type deriving from Database that supports parameter discovery.
除了这个程序,还有其他正确的方法吗?
编辑
Database db = CustomDbFactory.CreateDataBase(connStrName);
DbCommand command = db.DbProviderFactory.CreateCommand();
command.CommandText = @spName;
command.CommandType = CommandType.StoredProcedure;
db.DiscoverParameters(command);
...
该特性仅支持SqlDatabase
对象。因此,不是在GenericDatabase
上调用DiscoverParameters
,我必须从SqlDatabase
调用它。细节问题。