Pages

Friday, December 13, 2013

Waiting for all asynchronous tasks to finish

We recently had to revisit one of the reports of our system (a financial solution) because it was taking too long, anywhere between 20 to 40 minutes depending on the size of the Mutual/Hedge Fund Company). Basically, the report contained information about the positions of each account in a fund, things like Units held, Average Cost, Market Value, Series. Unfortunately, these numbers cannot be obtained through simple SQL aggregation functions like SUM or AVG and crunching the numbers results in an exercise a little harder than that which includes going through the transactions history of each account.

Monday, April 22, 2013

Set UpdateCheck to Never programatically for LINQ Data Contexts

By default when you generate a LINQ Data Context in Visual Studio, every column of every table has the UpdateCheck property set to Always. The implication of this is that the UPDATE sql statements issued by LINQ will include all the fields in the WHERE clause in order to match the exact copy of the record that was initially read and prevent overwriting changes made by other users/threads between the last time we read the record and the moment we try to update it. And that's fine in many scenarios but sometimes you want all the UPDATE statements to find the record to update and change it regardless of changes sent by others (a "last commit wins" type of policy) and for that you'd need LINQ's UPDATE statements to only include the table's primary key fields in the WHERE clause. That is, you need the UpdateCheck property set to Never for all the columns that are not primary keys.