开发者

Does/Can/Should subsonic natively handle database collisions?

I have recently picked up SubSonic to use in a new vb.net windows app project and so far I really love it! Its a perfect st开发者_JAVA百科art and written in a way, using t4 templates, which leaves it wide open to customisation.

Anyway, I'm using Active record and MySql. I have a form whose controls are databound to a subsonic dataclass using a bindingsource. When I:

  1. make some changes in the form BUT

  2. also change the data in the db table using the MySql workbench and then

  3. save the changes through the form

I get no warning/notification of the data collision? The workbench change is overwritten by calling Save() on the subsonic dataclass

This may not be a feature of subsonic yet or am I doing somthing wrong? If not I will add to the save code in the templates, so that I:

  1. load a fresh copy the record

  2. compare the existing record's timestamp to the fresh record's timestamp

  3. compare each field's data and build a collection of changes

  4. raise an event, with the changes collection in the eventargs so that I can get the user to decide wht to do.

I dont want to do this if its already done, thats all.


I get no warning/notification of the data collision? The workbench change is overwritten by calling Save() on the subsonic dataclass

This may not be a feature of subsonic yet or am I doing somthing wrong?

There are no optimistic concurrency features in SubSonic. Also, it is not "yet", it is "period" - there is no significant development occurring in the SubSonic project, and what development there is revolves around supporting Oracle (a goal that has long been unrealized).

If not I will add to the save code in the templates

I'm going to suggest that it will be more efficient for you to drop SubSonic and begin learning a different data access tool with more robust features, like Entity Framework or NHibernate. This will not likely be the last limitation you encounter with SubSonic.

If not I will add to the save code in the templates, so that I:

  1. load a fresh copy the record

  2. compare the existing record's timestamp to the fresh record's timestamp

  3. compare each field's data and build a collection of changes

  4. raise an event, with the changes collection in the eventargs so that I can get the user to decide wht to do.

It would be unnecessarily inefficient to begin by loading a fresh copy of the record. A better alternative would be to add a where clause to the update for the timestamp column so that the update will only occur if both the primary key and timestamp column match. You can detect a concurrency violation in this manner by checking the affected record count. If the affected record count is zero, the record has been updated or deleted, and then you can load a copy and begin conflict resolution.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜