I am using adapter for the first time and am struggling to get inserts on tables with a GUID PK to work:
When I call:
using (Adapter)
{
if (contract.IsNew)
contract.ContractId = Guid.NewGuid();
Adapter.SaveEntity(contract, true);
}
In researching other posts it was brought up that one should assign the guid before inserting because the identity could not be returned after insertion.
I get this message in the exception:
"An exception was caught during the execution of an action query: Operand type clash: numeric is incompatible with uniqueidentifier. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception."
the executed query looks like this:
Query: INSERT INTO [wsi].[dbo].[Contract_Contract] ([Description], [ContractTypeId], [VendorId], [BranchId], [AutoRenewing], [NonRenewalNotification], [Amount], [AmountPeriodId], [Buyout], [Comments], [IsActive]) VALUES (@Description, @ContractTypeId, @VendorId, @BranchId, @AutoRenewing, @NonRenewalNotification, @Amount, @AmountPeriodId, @Buyout, @Comments, @IsActive);SELECT @ContractId=SCOPE_IDENTITY()
Parameter: @ContractId : Guid. Length: 0. Precision: 0. Scale: 0. Direction: Output. Value: <undefined value>.
Parameter: @Description : String. Length: 255. Precision: 0. Scale: 0. Direction: Input. Value: test.
Parameter: @ContractTypeId : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 0.
Parameter: @VendorId : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 0.
Parameter: @BranchId : AnsiStringFixedLength. Length: 15. Precision: 0. Scale: 0. Direction: Input. Value: .
Parameter: @AutoRenewing : Boolean. Length: 0. Precision: 1. Scale: 0. Direction: Input. Value: False.
Parameter: @NonRenewalNotification : Boolean. Length: 0. Precision: 1. Scale: 0. Direction: Input. Value: False.
Parameter: @Amount : Currency. Length: 0. Precision: 19. Scale: 4. Direction: Input. Value: 0.
Parameter: @AmountPeriodId : AnsiStringFixedLength. Length: 1. Precision: 0. Scale: 0. Direction: Input. Value: .
Parameter: @Buyout : Currency. Length: 0. Precision: 19. Scale: 4. Direction: Input. Value: 0.
Parameter: @Comments : AnsiString. Length: 2147483647. Precision: 0. Scale: 0. Direction: Input. Value: .
Parameter: @IsActive : Boolean. Length: 0. Precision: 1. Scale: 0. Direction: Input. Value: False.