/// <summary>ArchiveChildrens a Currency record.</summary> /// <param name="transaction">Commits or rejects a set of commands as a unit</param> /// <param name="rowVersion">the version number of this row.</param> /// <param name="currencyId">The value for the CurrencyId column.</param> /// <param name="archive">true to archive the object, false to unarchive it.</param> internal new static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int currencyId) { // Accessor for the Currency Table. ServerDataModel.CurrencyDataTable currencyTable = ServerDataModel.Currency; // This record can be used to iterate through all the children. ServerDataModel.CurrencyRow currencyRow = currencyTable.FindByCurrencyId(currencyId); // Archive the child records. for (int index = 0; (index < currencyRow.GetAccountRows().Length); index = (index + 1)) { ServerDataModel.AccountRow childAccountRow = currencyRow.GetAccountRows()[index]; Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId); } for (int index = 0; (index < currencyRow.GetPriceRows().Length); index = (index + 1)) { ServerDataModel.PriceRow childPriceRow = currencyRow.GetPriceRows()[index]; Price.Archive(adoTransaction, sqlTransaction, childPriceRow.RowVersion, childPriceRow.SecurityId, childPriceRow.CurrencyId); } // Increment the row version rowVersion = ServerDataModel.RowVersion.Increment(); // Delete the record in the ADO database. currencyRow[currencyTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(currencyRow); currencyRow.Delete(); // Archive the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Currency\" set \"IsArchived\" = 1 where \"CurrencyId\"=@currencyId"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@currencyId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, currencyId)); sqlCommand.ExecuteNonQuery(); }
/// <summary>Archives a Price record.</summary> /// <param name="transaction">Commits or rejects a set of commands as a unit</param> /// <param name="RowVersion">The version number of this row.</param> /// <param name="securityId">The value for the SecurityId column.</param> /// <param name="currencyId">The value for the CurrencyId column.</param> /// <param name="archive">true to archive the object, false to unarchive it.</param> public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int securityId, int currencyId) { // Accessor for the Price Table. ServerDataModel.PriceDataTable priceTable = ServerDataModel.Price; // Rule #1: Make sure the record exists before updating it. ServerDataModel.PriceRow priceRow = priceTable.FindBySecurityIdCurrencyId(securityId, currencyId); if ((priceRow == null)) { throw new Exception(string.Format("The Price table does not have an element identified by {0}{0}", securityId, currencyId)); } // Rule #2: Optimistic Concurrency Check if ((priceRow.RowVersion != rowVersion)) { throw new System.Exception("This record is busy. Please try again later."); } // Archive the child records. // Increment the row version rowVersion = ServerDataModel.RowVersion.Increment(); // Delete the record in the ADO database. priceRow[priceTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(priceRow); priceRow.Delete(); // Archive the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Price\" set \"IsArchived\" = 1 where \"SecurityId\"=@securityId and \"CurrencyI" + "d\"=@currencyId"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId)); sqlCommand.Parameters.Add(new SqlParameter("@currencyId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, currencyId)); sqlCommand.ExecuteNonQuery(); }
/// <summary>Updates a Price record using Metadata Parameters.</summary> /// <param name="transaction">Contains the parameters and exceptions for this command.</param> public static void Update(ParameterList parameters) { // Accessor for the Price Table. ServerDataModel.PriceDataTable priceTable = ServerDataModel.Price; // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; object configurationId = parameters["configurationId"].Value; string externalSecurityId = parameters["securityId"]; string externalCurrencyId = parameters["currencyId"]; object closePrice = parameters["closePrice"].Value; object priceChange = parameters["priceChange"].Value; object lastPrice = parameters["lastPrice"].Value; object lastSize = parameters["lastSize"].Value; object bidPrice = parameters["bidPrice"].Value; object bidSize = parameters["bidSize"].Value; object askPrice = parameters["askPrice"].Value; object askSize = parameters["askSize"].Value; // The row versioning is largely disabled for external operations. long rowVersion = long.MinValue; // Resolve External Identifiers int securityId = Security.FindRequiredKey(configurationId, "securityId", externalSecurityId); int currencyId = Currency.FindRequiredKey(configurationId, "currencyId", externalCurrencyId); // This will bypass the internal optimistic concurrency checking by providing the current rowVersion to the // internal method. ServerDataModel.PriceRow priceRow = priceTable.FindBySecurityIdCurrencyId(securityId, currencyId); rowVersion = ((long)(priceRow[priceTable.RowVersionColumn])); // Call the internal method to complete the operation. MarkThree.Quasar.Core.Price.Update(adoTransaction, sqlTransaction, ref rowVersion, securityId, currencyId, closePrice, priceChange, lastPrice, lastSize, bidPrice, bidSize, askPrice, askSize); // Return values. parameters["rowVersion"] = rowVersion; }
/// <summary> /// Authorizes a Price to be returned to the client. /// </summary> /// <param name="userDataRow">Identifies the current user.</param> /// <param name="priceDataRow">The record to be tested for authorization.</param> /// <returns>true if the record belongs in the user's hierarchy.</returns> public static bool FilterPrice(DataRow userDataRow, DataRow priceDataRow) { // This will test the record and return true if it belongs to the hierarchies this user is authorized to view. False // if the record should not be included in the user's data model. ServerDataModel.UserRow userRow = (ServerDataModel.UserRow)userDataRow; ServerDataModel.PriceRow priceRow = (ServerDataModel.PriceRow)priceDataRow; return(true); }
/// <summary>Archives a Price record using Metadata Parameters.</summary> /// <param name="transaction">Contains the parameters and exceptions for this command.</param> public static void Archive(ParameterList parameters) { // Accessor for the Price Table. ServerDataModel.PriceDataTable priceTable = ServerDataModel.Price; // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; object configurationId = parameters["configurationId"].Value; string externalSecurityId = parameters["securityId"]; string externalCurrencyId = parameters["currencyId"]; // Resolve External Identifiers int securityId = Security.FindRequiredKey(configurationId, "securityId", externalSecurityId); int currencyId = Currency.FindRequiredKey(configurationId, "currencyId", externalCurrencyId); // The row versioning is largely disabled for external operations. long rowVersion = long.MinValue; // While the optimistic concurrency checking is disabled for the external methods, the internal methods // still need to perform the check. This ncurrency checking logic by finding the current row version to be // will bypass the coused when the internal method is called. ServerDataModel.PriceRow priceRow = priceTable.FindBySecurityIdCurrencyId(securityId, currencyId); rowVersion = ((long)(priceRow[priceTable.RowVersionColumn])); // Call the internal method to complete the operation. MarkThree.Quasar.Core.Price.Archive(adoTransaction, sqlTransaction, rowVersion, securityId, currencyId); }
/// <summary>ArchiveChildrens a Security record.</summary> /// <param name="transaction">Commits or rejects a set of commands as a unit</param> /// <param name="rowVersion">the version number of this row.</param> /// <param name="securityId">The value for the SecurityId column.</param> /// <param name="archive">true to archive the object, false to unarchive it.</param> internal static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int securityId) { // Accessor for the Security Table. ServerDataModel.SecurityDataTable securityTable = ServerDataModel.Security; // This record can be used to iterate through all the children. ServerDataModel.SecurityRow securityRow = securityTable.FindBySecurityId(securityId); // Archive the child records. for (int index = 0; (index < securityRow.GetAccountRows().Length); index = (index + 1)) { ServerDataModel.AccountRow childAccountRow = securityRow.GetAccountRows()[index]; Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId); } for (int index = 0; (index < securityRow.GetAllocationRowsByFKSecurityAllocationSecurityId().Length); index = (index + 1)) { ServerDataModel.AllocationRow childAllocationRow = securityRow.GetAllocationRowsByFKSecurityAllocationSecurityId()[index]; Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId); } for (int index = 0; (index < securityRow.GetAllocationRowsByFKSecurityAllocationSettlementId().Length); index = (index + 1)) { ServerDataModel.AllocationRow childAllocationRow = securityRow.GetAllocationRowsByFKSecurityAllocationSettlementId()[index]; Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId); } for (int index = 0; (index < securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSecurityId().Length); index = (index + 1)) { ServerDataModel.BlockOrderRow childBlockOrderRow = securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSecurityId()[index]; BlockOrder.Archive(adoTransaction, sqlTransaction, childBlockOrderRow.RowVersion, childBlockOrderRow.BlockOrderId); } for (int index = 0; (index < securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSettlementId().Length); index = (index + 1)) { ServerDataModel.BlockOrderRow childBlockOrderRow = securityRow.GetBlockOrderRowsByFKSecurityBlockOrderSettlementId()[index]; BlockOrder.Archive(adoTransaction, sqlTransaction, childBlockOrderRow.RowVersion, childBlockOrderRow.BlockOrderId); } for (int index = 0; (index < securityRow.GetBlotterMapRows().Length); index = (index + 1)) { ServerDataModel.BlotterMapRow childBlotterMapRow = securityRow.GetBlotterMapRows()[index]; BlotterMap.Archive(adoTransaction, sqlTransaction, childBlotterMapRow.RowVersion, childBlotterMapRow.BlotterMapId); } for (int index = 0; (index < securityRow.GetDebtRowsByFKSecurityDebtDebtId().Length); index = (index + 1)) { ServerDataModel.DebtRow childDebtRow = securityRow.GetDebtRowsByFKSecurityDebtDebtId()[index]; Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId); } for (int index = 0; (index < securityRow.GetDebtRowsByFKSecurityDebtSettlementId().Length); index = (index + 1)) { ServerDataModel.DebtRow childDebtRow = securityRow.GetDebtRowsByFKSecurityDebtSettlementId()[index]; Debt.ArchiveChildren(adoTransaction, sqlTransaction, childDebtRow.RowVersion, childDebtRow.DebtId); } for (int index = 0; (index < securityRow.GetCurrencyRows().Length); index = (index + 1)) { ServerDataModel.CurrencyRow childCurrencyRow = securityRow.GetCurrencyRows()[index]; Currency.ArchiveChildren(adoTransaction, sqlTransaction, childCurrencyRow.RowVersion, childCurrencyRow.CurrencyId); } for (int index = 0; (index < securityRow.GetEquityRowsByFKSecurityEquityEquityId().Length); index = (index + 1)) { ServerDataModel.EquityRow childEquityRow = securityRow.GetEquityRowsByFKSecurityEquityEquityId()[index]; Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId); } for (int index = 0; (index < securityRow.GetEquityRowsByFKSecurityEquitySettlementId().Length); index = (index + 1)) { ServerDataModel.EquityRow childEquityRow = securityRow.GetEquityRowsByFKSecurityEquitySettlementId()[index]; Equity.ArchiveChildren(adoTransaction, sqlTransaction, childEquityRow.RowVersion, childEquityRow.EquityId); } for (int index = 0; (index < securityRow.GetOrderRowsByFKSecurityOrderSecurityId().Length); index = (index + 1)) { ServerDataModel.OrderRow childOrderRow = securityRow.GetOrderRowsByFKSecurityOrderSecurityId()[index]; Order.Archive(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId); } for (int index = 0; (index < securityRow.GetOrderRowsByFKSecurityOrderSettlementId().Length); index = (index + 1)) { ServerDataModel.OrderRow childOrderRow = securityRow.GetOrderRowsByFKSecurityOrderSettlementId()[index]; Order.Archive(adoTransaction, sqlTransaction, childOrderRow.RowVersion, childOrderRow.OrderId); } for (int index = 0; (index < securityRow.GetPositionRows().Length); index = (index + 1)) { ServerDataModel.PositionRow childPositionRow = securityRow.GetPositionRows()[index]; Position.Archive(adoTransaction, sqlTransaction, childPositionRow.RowVersion, childPositionRow.AccountId, childPositionRow.SecurityId, childPositionRow.PositionTypeCode); } for (int index = 0; (index < securityRow.GetPositionTargetRows().Length); index = (index + 1)) { ServerDataModel.PositionTargetRow childPositionTargetRow = securityRow.GetPositionTargetRows()[index]; PositionTarget.Archive(adoTransaction, sqlTransaction, childPositionTargetRow.RowVersion, childPositionTargetRow.ModelId, childPositionTargetRow.SecurityId, childPositionTargetRow.PositionTypeCode); } for (int index = 0; (index < securityRow.GetPriceRows().Length); index = (index + 1)) { ServerDataModel.PriceRow childPriceRow = securityRow.GetPriceRows()[index]; Price.Archive(adoTransaction, sqlTransaction, childPriceRow.RowVersion, childPriceRow.SecurityId, childPriceRow.CurrencyId); } for (int index = 0; (index < securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSecurityId().Length); index = (index + 1)) { ServerDataModel.ProposedOrderRow childProposedOrderRow = securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSecurityId()[index]; ProposedOrder.Archive(adoTransaction, sqlTransaction, childProposedOrderRow.RowVersion, childProposedOrderRow.ProposedOrderId); } for (int index = 0; (index < securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSettlementId().Length); index = (index + 1)) { ServerDataModel.ProposedOrderRow childProposedOrderRow = securityRow.GetProposedOrderRowsByFKSecurityProposedOrderSettlementId()[index]; ProposedOrder.Archive(adoTransaction, sqlTransaction, childProposedOrderRow.RowVersion, childProposedOrderRow.ProposedOrderId); } for (int index = 0; (index < securityRow.GetTaxLotRows().Length); index = (index + 1)) { ServerDataModel.TaxLotRow childTaxLotRow = securityRow.GetTaxLotRows()[index]; TaxLot.Archive(adoTransaction, sqlTransaction, childTaxLotRow.RowVersion, childTaxLotRow.TaxLotId); } for (int index = 0; (index < securityRow.GetViolationRows().Length); index = (index + 1)) { ServerDataModel.ViolationRow childViolationRow = securityRow.GetViolationRows()[index]; Violation.Archive(adoTransaction, sqlTransaction, childViolationRow.RowVersion, childViolationRow.ViolationId); } // Increment the row version rowVersion = ServerDataModel.RowVersion.Increment(); // Delete the record in the ADO database. securityRow[securityTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(securityRow); securityRow.Delete(); // Archive the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Security\" set \"IsArchived\" = 1 where \"SecurityId\"=@securityId"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId)); sqlCommand.ExecuteNonQuery(); }
/// <summary>Inserts a Price record.</summary> /// <param name="transaction">Commits or rejects a set of commands as a unit</param> /// <param name="securityId">The value for the SecurityId column.</param> /// <param name="currencyId">The value for the CurrencyId column.</param> /// <param name="closePrice">The value for the ClosePrice column.</param> /// <param name="priceChange">The value for the PriceChange column.</param> /// <param name="lastPrice">The value for the LastPrice column.</param> /// <param name="lastSize">The value for the LastSize column.</param> /// <param name="bidPrice">The value for the BidPrice column.</param> /// <param name="bidSize">The value for the BidSize column.</param> /// <param name="askPrice">The value for the AskPrice column.</param> /// <param name="askSize">The value for the AskSize column.</param> public static void Insert(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, int securityId, int currencyId, object closePrice, object priceChange, object lastPrice, object lastSize, object bidPrice, object bidSize, object askPrice, object askSize) { // Accessor for the Price Table. ServerDataModel.PriceDataTable priceTable = ServerDataModel.Price; // Apply Defaults if ((closePrice == null)) { closePrice = 0.0m; } if ((priceChange == null)) { priceChange = 0.0m; } if ((lastPrice == null)) { lastPrice = 0.0m; } if ((lastSize == null)) { lastSize = 0.0m; } if ((bidPrice == null)) { bidPrice = 0.0m; } if ((bidSize == null)) { bidSize = 0.0m; } if ((askPrice == null)) { askPrice = 0.0m; } if ((askSize == null)) { askSize = 0.0m; } // Increment the row version rowVersion = ServerDataModel.RowVersion.Increment(); // Insert the record into the ADO database. ServerDataModel.PriceRow priceRow = priceTable.NewPriceRow(); priceRow[priceTable.RowVersionColumn] = rowVersion; priceRow[priceTable.SecurityIdColumn] = securityId; priceRow[priceTable.CurrencyIdColumn] = currencyId; priceRow[priceTable.ClosePriceColumn] = closePrice; priceRow[priceTable.PriceChangeColumn] = priceChange; priceRow[priceTable.LastPriceColumn] = lastPrice; priceRow[priceTable.LastSizeColumn] = lastSize; priceRow[priceTable.BidPriceColumn] = bidPrice; priceRow[priceTable.BidSizeColumn] = bidSize; priceRow[priceTable.AskPriceColumn] = askPrice; priceRow[priceTable.AskSizeColumn] = askSize; priceTable.AddPriceRow(priceRow); adoTransaction.DataRows.Add(priceRow); // Insert the record into the SQL database. SqlCommand sqlCommand = new SqlCommand("insert \"Price\" (\"rowVersion\",\"SecurityId\",\"CurrencyId\",\"ClosePrice\",\"LastPrice\",\"" + "LastSize\",\"BidPrice\",\"BidSize\",\"AskPrice\",\"AskSize\") values (@rowVersion,@securi" + "tyId,@currencyId,@closePrice,@lastPrice,@lastSize,@bidPrice,@bidSize,@askPrice,@" + "askSize)"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion)); sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId)); sqlCommand.Parameters.Add(new SqlParameter("@currencyId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, currencyId)); sqlCommand.Parameters.Add(new SqlParameter("@closePrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, closePrice)); sqlCommand.Parameters.Add(new SqlParameter("@lastPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, lastPrice)); sqlCommand.Parameters.Add(new SqlParameter("@lastSize", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, lastSize)); sqlCommand.Parameters.Add(new SqlParameter("@bidPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, bidPrice)); sqlCommand.Parameters.Add(new SqlParameter("@bidSize", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, bidSize)); sqlCommand.Parameters.Add(new SqlParameter("@askPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, askPrice)); sqlCommand.Parameters.Add(new SqlParameter("@askSize", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, askSize)); sqlCommand.ExecuteNonQuery(); }
/// <summary>Updates a Price record.</summary> /// <param name="transaction">Commits or rejects a set of commands as a unit</param> /// <param name="rowVersion">The version number of the row</param> /// <param name="securityId">The value for the SecurityId column.</param> /// <param name="currencyId">The value for the CurrencyId column.</param> /// <param name="closePrice">The value for the ClosePrice column.</param> /// <param name="priceChange">The value for the PriceChange column.</param> /// <param name="lastPrice">The value for the LastPrice column.</param> /// <param name="lastSize">The value for the LastSize column.</param> /// <param name="bidPrice">The value for the BidPrice column.</param> /// <param name="bidSize">The value for the BidSize column.</param> /// <param name="askPrice">The value for the AskPrice column.</param> /// <param name="askSize">The value for the AskSize column.</param> public static void Update(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, ref long rowVersion, int securityId, int currencyId, object closePrice, object priceChange, object lastPrice, object lastSize, object bidPrice, object bidSize, object askPrice, object askSize) { // Accessor for the Price Table. ServerDataModel.PriceDataTable priceTable = ServerDataModel.Price; // Rule #1: Make sure the record exists before updating it. ServerDataModel.PriceRow priceRow = priceTable.FindBySecurityIdCurrencyId(securityId, currencyId); if ((priceRow == null)) { throw new Exception(string.Format("The Price table does not have an element identified by {0}{0}", securityId, currencyId)); } // Rule #2: Optimistic Concurrency Check if ((priceRow.RowVersion != rowVersion)) { throw new System.Exception("This record is busy. Please try again later."); } // Apply Defaults if ((closePrice == null)) { closePrice = priceRow[priceTable.ClosePriceColumn]; } if ((priceChange == null)) { priceChange = priceRow[priceTable.PriceChangeColumn]; } if ((lastPrice == null)) { lastPrice = priceRow[priceTable.LastPriceColumn]; } if ((lastSize == null)) { lastSize = priceRow[priceTable.LastSizeColumn]; } if ((bidPrice == null)) { bidPrice = priceRow[priceTable.BidPriceColumn]; } if ((bidSize == null)) { bidSize = priceRow[priceTable.BidSizeColumn]; } if ((askPrice == null)) { askPrice = priceRow[priceTable.AskPriceColumn]; } if ((askSize == null)) { askSize = priceRow[priceTable.AskSizeColumn]; } // Increment the row version rowVersion = ServerDataModel.RowVersion.Increment(); // Update the record in the ADO database. priceRow[priceTable.RowVersionColumn] = rowVersion; priceRow[priceTable.ClosePriceColumn] = closePrice; priceRow[priceTable.PriceChangeColumn] = priceChange; priceRow[priceTable.LastPriceColumn] = lastPrice; priceRow[priceTable.LastSizeColumn] = lastSize; priceRow[priceTable.BidPriceColumn] = bidPrice; priceRow[priceTable.BidSizeColumn] = bidSize; priceRow[priceTable.AskPriceColumn] = askPrice; priceRow[priceTable.AskSizeColumn] = askSize; adoTransaction.DataRows.Add(priceRow); // Update the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Price\" set \"RowVersion\"=@rowVersion,\"ClosePrice\"=@closePrice,\"LastPrice\"=" + "@lastPrice,\"LastSize\"=@lastSize,\"BidPrice\"=@bidPrice,\"BidSize\"=@bidSize,\"AskPric" + "e\"=@askPrice,\"AskSize\"=@askSize where \"SecurityId\"=@securityId and \"CurrencyId\"=" + "@currencyId"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion)); sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId)); sqlCommand.Parameters.Add(new SqlParameter("@currencyId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, currencyId)); sqlCommand.Parameters.Add(new SqlParameter("@closePrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, closePrice)); sqlCommand.Parameters.Add(new SqlParameter("@lastPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, lastPrice)); sqlCommand.Parameters.Add(new SqlParameter("@lastSize", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, lastSize)); sqlCommand.Parameters.Add(new SqlParameter("@bidPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, bidPrice)); sqlCommand.Parameters.Add(new SqlParameter("@bidSize", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, bidSize)); sqlCommand.Parameters.Add(new SqlParameter("@askPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, askPrice)); sqlCommand.Parameters.Add(new SqlParameter("@askSize", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, askSize)); // Update the record in the SQL database. sqlCommand.ExecuteNonQuery(); }