个人开发框架总结(一)
2009-05-05 08:27:23 来源:WEB开发网ParameterPrefix 当前数据操作的存储过程参数名称的前缀,如SqlServer的@和Oracle的:
下面是具体的操作类型,SqlServer、Oracle、OleDb都是继承自DataHelper的,但并未为每一个操作类都写出各种数据操作的方法,这也主要是为了好维护,这几个类同时实现IDataProvider接口,这个接口就是为每种类型提供DbConnection、DbParameter、DataAdapter、DbCommand等。如SqlServer里是这样写到的:
public class SqlServer : DataHelper, IDataProvider
{
#region IDataConverter
IDbConnection IDataProvider.GetDbConnection()
{
SqlConnection conn = new SqlConnection(ConnectionString);
conn.StateChange += new StateChangeEventHandler(base.OnStateChange);
return conn;
}
IDbDataAdapter IDataProvider.GetDataAdapter()
{
return new SqlDataAdapter();
}
IDataParameter IDataProvider.GetParameter()
{
return new SqlParameter();
}
IDataParameter[] IDataProvider.GetParameters(int Count)
{
return new SqlParameter[Count];
}
IDbCommand IDataProvider.GetCommand(IDbCommand command)
{
return command as SqlCommand;
}
void IDataProvider.GetCommandBuilder(IDbDataAdapter DataAdapter, DataTable DataTable, DataViewRowState dataViewRowState)
{
SqlDataAdapter adapter = (SqlDataAdapter)DataAdapter;
SqlCommandBuilder cmdb = new SqlCommandBuilder(adapter);
}
#endregion
}
更多精彩
赞助商链接