Data Provider Timestamp Abstraction

Data Provider Timestamp Abstraction

Old forum URL: forums.lhotka.net/forums/t/629.aspx


WyattRidesAgain posted on Friday, July 14, 2006

I'm trying to use CSLA with MySQL.  I'm also trying to abstract the specifics of accessing data providers out of the business classes so I can more easily migrate to other databases in the future if need be (most likely MS SQL, Access, or Oracle).  I've done much of the data access abstraction already via a separate DataAccessLayer dll which works well, but am stuck with what to do about TimeStamp columns which are used for optimistic locking.

PTracker in the CSLA download uses MS SQL with its binary-based TimeStamp datatype.  MySQL uses a DateTime-based TimeStamp datatype.  I'm not sure offhand what format Oracle's TimeStamp may be.  Given my still-growing experience with OO design, I'd appreciate any suggestions on an approach to do the abstraction. 

Thanks,

Wyatt

 

chriss replied on Monday, July 17, 2006

Hi,

You could always just use a normal datetime field. i.e. table has a MODIFIED column that gets set to current date on record creation.  Then in the stored proc/sql code add to the update criteria somthing along the lines of:

where ID = @ID

... and MODIFIED < @NEW_MODIFIED

Otherwise works exactly the same as the timestamp in the PTRacker example. Using a normal Datetime datatype will be compatible with all RDBMS platforms. 

 

WyattRidesAgain replied on Monday, July 17, 2006

Chriss,

Thanks for the suggestion!  I like its simplicity.  I think I was making this too complicated, no doubt from my inexperience.

Wyatt

Copyright (c) Marimer LLC