What you need is optimistic concurrency
on your UPDATE
statement, not to exclude certain fields. In short what that means is when updating a table, a WHERE
clause is appended to your UPDATE
statement that ensures the values of the fields in the row are in fact what they were when the last SELECT
was run.
So, let's assume in your example I selected some data and the values for A
and B
were 1
and 2
respectively. Now let's assume I wanted to update B
(below statement is just an example):
UPDATE TestClass SET B = '3' WHERE Id = 1;
However, instead of running that statement (because there's no concurrency there), let's run this one:
UPDATE TestClass SET B = '3' WHERE Id = 1 AND A = '1' AND B = '2';
That statement now ensures the record hasn't been changed by anybody.
However, at the moment it doesn't appear that Subsonic's SimpleRepository supports any type of concurrency and so that's going to be a major downfall. If you're looking for a very straight forward repository library, where you can use POCO's, I would recommend Dapper. In fact, Dapper is used by Stackoverflow. It's extremely fast and will easily allow you to build in concurrency into your update statements because you send down parameterized SQL statements, simple.
- This Stackoverflow article is an overall article on how to use Dapper for all CRUD ops.
- This Stackoverflow article shows how to perform inserts and updates with Dapper.
NOTE: with Dapper you could actually do what you're wanting to as well because you send down basic SQL statements, but I just wouldn't recommend not using concurrency.