public static DbDataAdapter CreateDataAdapter(GmConnection conn, Document doc) { DbDataAdapter da = conn.CreateDataAdapter(); GmCommand cmd = conn.CreateCommand(selectCmdText); cmd.AddInt("DocumentId", doc.DocumentId); cmd.AddBool("FactFlag", false); (da as IDbDataAdapter).SelectCommand = cmd.DbCommand; cmd = conn.CreateCommand(insertCmdText); cmd.AddString("ProductCode").SourceColumn = "ProductCode"; cmd.AddString("UnitCode").SourceColumn = "UnitCode"; cmd.AddInt("DocumentId", doc.DocumentId); cmd.AddDecimal("Coef").SourceColumn = "Coef"; cmd.AddDecimal("Count").SourceColumn = "Count"; cmd.AddBool("FactFlag", true); cmd.AddBool("HandledFlag").SourceColumn = "HandledFlag"; cmd.DbCommand.UpdatedRowSource = UpdateRowSource.FirstReturnedRecord; (da as IDbDataAdapter).InsertCommand = cmd.DbCommand; cmd = conn.CreateCommand(deleteCmdText); cmd.AddInt("DocumentProductId").SourceColumn = "DocumentProductId"; (da as IDbDataAdapter).DeleteCommand = cmd.DbCommand; cmd = conn.CreateCommand(updateCmdText); cmd.AddInt("DocumentProductId").SourceColumn = "DocumentProductId"; cmd.AddDecimal("Count").SourceColumn = "Count"; cmd.AddBool("HandledFlag").SourceColumn = "HandledFlag"; (da as IDbDataAdapter).UpdateCommand = cmd.DbCommand; return(da); }