I have some legacy code that I'm rewriting using SubSonic to help the future maintainers. For the most part it's been relatively simple, as everything makes a stored procedure call. But now I'm having some difficulty with some tightly-coupled ADO.NET code.
The code depends on the SqlDataAdapter to decide when to call an INSERT or UPDATE stored proc, which I understand. How can I rewrite this code in a SubSonic way?
public void SaveInvoice(InvoiceItems invoiceItems)
{
// extraneous code removed
// invoiceItems is a dataset
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "InvoiceItem_INSERT";
cmd.Connection = conn;
updateCmd.CommandType = CommandType.StoredProcedure;
updateCmd.CommandText = "InvoiceItem_UPDATE";
updateCmd.Connection = conn;
SqlCommandBuilder.DeriveParameters(cmd);
SqlCommandBuilder.DeriveParameters(updateCmd);
adapter.InsertCommand = cmd;
adapter.UpdateCommand = updateCmd;
adapter.Update(invoiceItems._InvoiceItemTable);
}
I'm new to SubSonic, so any help is appreciated. All helpful answers will be gleefully upvoted.