StrataFrame Forum

Insert with Complex PK including identity field

http://forum.strataframe.net/Topic28513.aspx

By Lukasz Kustusz - 9/28/2010

Hello,

I'm running into problems trying to insert a record into a BO which has multi-field PK, where one of the fields is identity.

Initially I was getting the error as in post http://forum.strataframe.net/Topic26039.aspx. Problem is that when I set 
PrimaryKeyIsUpdable=False
PrimaryKeyIsAutoIncremented=True
I get the following error:
"Cannot create INSERT command because a business object with PrimaryKeyIsAutoIncremented = True must have exactly 1 primary key field."
What else should I try?
By Lukasz Kustusz - 9/28/2010

OK, never mind. I recreated the key to include only the identity field (the other two fields were redundant) and it all worked fine.
By Greg McGuffey - 9/28/2010

Glad you got is working. There are times when I have both an identity field (which I make the PK as you ended up doing) and also another multi-field unique key, which is more business rule related. If this is the case, then I just make a unique index on the other key, which enforces the business rule at the DB level.