I have found several questions related to System.DateTime which cover a similar problem. However, it seemed none of them really initialized something.
I am using an
My Player class contains a DateTime field.
I have a function to get a Player object and create a new Player object. (As I cannot access the Session object from outside the service that holds these query functions.)
In my final application I have two functions which are more or less similar to this.
When I attempt to retrieve the second player the following exception is thrown:
Now, from what I understand from the other issues (which are quite old and based on older DO versions) it's because an incorrect DateTime value is used to initialize this. Bugs have been filed but I have not found any bug that was fixed or any mention of a solution. I could of course create my own private structures to handle a DateTime object properly and use the OnInitialize() override to convert those into a System.DateTime, but that seems like a lot of unneeded work.
What's the proper solution to handle DateTime objects?
asked Apr 13 '11 at 06:22
As you use SessionOptions.ClientProfile, DataObjects.Net utilizes entity versions for optimistic concurrency control support. By default, all non-lazy fields are used to produce a version of an entity (a snapshot of it), but it is better to set up version-related fields explicitly. For example, in your model I'd recommend to follow this approach:
Thus, VersionInfo would include only 1 int field, moreover, this would save you from the VersionConflictException you were being disturbed by.
answered Apr 18 '11 at 07:01