Otis wrote:
You can't set identity fields unless you set the Table manually into the mode to update identity fields. SqlServer has a statement for that: SET IDENTITY_INSERT. This isn't directly supported by LLBLGen Pro.
I don't understand the answer. Firebird, for example, lets me easily change a primary key using an UPDATE statment and takes care of all foreign keys that are affected. I was trying to accomplish this with LLBLGen, but it didn't work. If I change the ID (works fine) and call adapter.SaveEntity(), nothing happens at all (There is not UPDATE statement generated at all). Is there a reason this doesn't work? The designer implies it should, as I can uncheck the "Is readonly" checkbox of my identity in the designer...
Identity handling seems to be a bit of a problem - there are quite a few postings that address these very issues, and since I started thinking about using LLBLGen, I already got 3 projects (of a total of 3 projects) coming where I need custom ID handling AND identities. I'm thinking about skipping Identity columns completely and calling my sequence procedures before saving my IDs manually - this would give me the freedom I need. Is there a recommended pattern to do so with a somewhat low overhead? Some thoughts I had:
- before an entity is saved the first time, call the sequence (or an SP that calls the sequence and returns the ID). However, I'm not sure what this means in terms of overhead (I guess I had to acquire a connection each time).
- before a save of a collection, call a procedure and request [x] IDs, where [x] is the number of new entities in the collection. The procedure would call the sequence [x] times and return all IDs at once. Then, I assign the IDs manually before calling adapter.SaveEntityCollection(). However, I don't know where to place this code.
- [a better solution]
Thanks for the clarification
Philipp