Automatically creates Commands for MultiTableDataAdapter Fill and Update operations.
For a list of all members of this type, see CommandBuilder Members.
System.Object
Hydrus.DataSetToolkit.CommandBuilder
Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.
The primary advantage of the Hydrus Software CommandBuilder over framework provided command builders is that it will generate ANSI compliant SELECT commands. When the MultiTableDataAdapter is registered with a CommandBuilder, you need not set a select command before using the adapter's fill and update operations. This allows a greater flexibility in using the MultiTableDataAdapter in a dynamic situation. You will never need to create different commands for each table you wish to fill in your DataSet.
Simple c# example using the MultiTableDataAdapter: note: this example assumes a typed DataSet with a table Customer having rows CustomerId, FirstName, and LastName
using System;
using System.Data;
using Hydrus.DataSetToolkit;
class SimpleTest
{
MyNamespace.MyTypedDataSet dataSet;
public SimpleTest()
{
dataSet = new MyNamespace.MyTypedDataSet();
}
[STAThread]
public static void Main(string[] args)
{
MultiTableDataAdapter multiTableAdapter = new MultiTableDataAdapter(args[0]);
CommandBuilder hydrusBuilder = new CommandBuilder(DatabaseProvider.SqlServer,
multiTableAdapter,args[1])
MyNamespace.MyTypedDataSet.CustomerRow customer =
(MyNamespace.MyTypedDataSet.CustomerRow)multiTableAdapter.FillAndFindRow(
dataSet.Customer, Int32.Parse(args[2]));
Console.WriteLine(String.Format(
"Customer found with given ID ({0}). First Name:{1} ; Last Name: {2})
,args[2]
,customer.FirstName
,customer.LastName);
}
}
While the CommandBuilder
must be initialized with a MultiTableDataAdapter, you can directly access
the generated commands without using the adapter's operations. This may
be useful when refactoring existing code, or when exposing framework types
outside your own assembly. Using the CommandBuilder without using the
MultiTableDataAdapter:
MultiTableDataAdapter hydrusAdapter = new MultiTableDataAdapter(providerInvariantString); CommandBuilder hydrusBuilder = new CommandBuilder(hydrusAdapter); SqlDataAdapter sqlCustomerAdapter = new SqlDataAdapter(); sqlCustomerAdapter.SelectCommand = new SqlCommand(hydrusBuilder.CreateSelectCommand(myDataSet.Customers)); sqlCustomerAdapter.Fill(myDataSet);
Namespace: Hydrus.DataSetToolkit
Assembly: DataSetToolkit (in DataSetToolkit.dll)
CommandBuilder Members | Hydrus.DataSetToolkit Namespace | MultiTableDataAdapter | DbCommandBuilder | Hydrus.DataSetToolkit