protected override void BuildAdapter() { if (_dbDataAdapter != null) { return; } _dbDataAdapter = new SqlDataAdapter(); _dbDataAdapter.InsertCommand = new SqlCommand(); _dbDataAdapter.InsertCommand.Connection = _context.Connection; _dbDataAdapter.UpdateCommand = new SqlCommand(); _dbDataAdapter.UpdateCommand.Connection = _context.Connection; _dbDataAdapter.SelectCommand = new SqlCommand(); _dbDataAdapter.SelectCommand.Connection = _context.Connection; _dbDataAdapter.DeleteCommand = new SqlCommand(); _dbDataAdapter.DeleteCommand.Connection = _context.Connection; // Builds up select sp string spName = TempSqlObjNameGenerator.GetSpName(); TableSpBuilder builder = new TableSpBuilder(); string spDDLsql = builder.BuildSelectSpDDL(_dbDataAdapter.SelectCommand.Parameters, spName, _context); SetupAdapterCommands(_dbDataAdapter.SelectCommand, spName, spDDLsql); // Builds up insert sp //spName = TempSqlObjNameGenerator.GetSpName(); //spDDLsql = builder.BuildInsertSpDDL(_dbDataAdapter.InsertCommand.Parameters, spName, _context); //SetupAdapterCommands(_dbDataAdapter.InsertCommand, spName, spDDLsql); }
protected override void BuildAdapter() { if (_dbDataAdapter != null) { return; } _dbDataAdapter = new SqlDataAdapter(); _dbDataAdapter.UpdateCommand = new SqlCommand(); _dbDataAdapter.UpdateCommand.Connection = _context.Connection; _dbDataAdapter.RowUpdated += new SqlRowUpdatedEventHandler(OnRowUpdated); _dbDataAdapter.ContinueUpdateOnError = true; string spName = TempSqlObjNameGenerator.GetSpName(); TableSpBuilder builder = new TableSpBuilder(); string spDDLsql = builder.BuildUpdateSpDDL(_dbDataAdapter.UpdateCommand.Parameters, spName, _context); SetupAdapterCommands(_dbDataAdapter.UpdateCommand, spName, spDDLsql); _dbDataAdapter.InsertCommand = _dbDataAdapter.UpdateCommand; // Empty DataTable ==> Fill data (for update or overwrite) // ==> _adapter.Update() ==> call 'InsertCommand' == in fact UpdateCommand called }