By S.Luann
In ADO.Net, DataAdapter is the main component used as data providers.
A newer component TableAdapter is more flexible to be used to build DAL and Domain model
DataSet Designer is a wizard to create Datasets and TableAdapters from a given data source, usually a database.
TableAdapter has Fill, Update, Insert, Delete methods. In addition it can has more Fills,
TableAdapter.FillByCity(@city);
TableAdapter.FillByCompany(@company);
these typed methods share the same schema of the DataTable. i.e. they fill a table with the same schema or return a scalar value.
These encapsulation is benifical when we need the flexibility to fill in different ways.
TableAdapter support both SQL statement or stored procedure/.
In order to execute these methods, TableAdapter has SelectCommand, UpdateCommand, DeleteCommand, and InsertCommand. the definition of these commands are something like the following:
class UpdateCommand()
{
sqlCommand cmd = new SqlCommand();
cmd.CommandType = storedProc | text;
cmd.Text = "blabla";
SqlConnection conn = new SqlConnection(connectionString);
SqlParameter[] params = new SqlParameter[]();
params.Add(param1);
..
}
No comments:
Post a Comment