OK, now I've got a real problem.
I'm successfully injecting the SET IDENTITY_INSERT into the query. (Only funny thing is I cannot see the query text in Visual Studio debugger, but i just prepended and appended the text and had faith it would work).
public override void OnSaveEntity(IActionQuery saveQuery, IEntity2 entityToSave)
{
if (entityToSave.LLBLGenProEntityName == "FieldEntity")
saveQuery.Command.CommandText = "SET IDENTITY_INSERT Field ON;" + saveQuery.Command.CommandText + ";SET IDENTITY_INSERT Field OFF;";
...
base.OnSaveEntity(saveQuery, entityToSave);
}
The entity has a primary key value set. But it's not getting put into the sql statement.
exec sp_executesql N'SET IDENTITY_INSERT Field ON;INSERT INTO [Completions].[dbo].[Field] ([Field],[OperationsOfficeID]) VALUES (@Field,@OperationsOfficeID);SELECT @FieldID=SCOPE_IDENTITY();SET IDENTITY_INSERT Field OFF;', N'@FieldID int output,@Field nvarchar(30),@OperationsOfficeID int', @FieldID = @P1 output, @Field = N'fldnm', @OperationsOfficeID = 6
Of course, now that I think about it, this makes sense. I assume I will have to take an additional step here and tell LLBLGenPro that this field is not an identity column so it will include that value?
Please help! I'm doing a demo tomorrow morning!!