Hi,
Ran into a small issue that I can't quite figure out while creating new entities that have default values set on insert. This is with SelfService.
For testing I created a very simple table that contains a Guid that is a PK and name field. The Guid has default value of (newid()) so it should generate a new GUID when inserted:
TestTableEntity table = new TestTableEntity();
// table.id = Guid.New();
table.Name = "rick";
table.Save();
Console.WriteLine(table.Id); // { 00...}
The save works and I get a new record in the DB but along with a new Guid, but after the Save() the entity's Id property is not updated. It remains at Guid.Empty(). An explicit Refetch also doesn't help in this case.
Worse a subsequent change and save will fail because the entity is marked as Fetched but in effect has no PK.
According to the documentation it sounds like a Save() followed by any property access should do an automatic refetch of the data and that is indeed happening but it's using the Guid.Empty() on the subsequent DB call.
I realize there's an easy fix for this here by just pre-assigning the Guid before saving but I'm trying to understand why this doesn't work here, while it does work when I use an AutoInc integer field (which is why I didn't notice this until now :-}).
What determines whether the PK is being retrieved after an update? Auto-inc on the field?
+++ Rick ---