Page 1 of 1

Invalid SQL generated?

Posted: Thu 07 Jul 2011 22:30
by fmarakasov
Hello. Here is an example, with failed SubmitChanges()

Code: Select all

using (var ctx = new MyDataContext())
{
       var contractdoc = ctx.Contractdocs.First();
       var newApproval = new Approveprocess(){Location = ctx.Locations.First(), Approvalstate = ctx.Locations().First(), Enterstateat = DateTime.Today};
       contractdoc.Approvalprocess.Add(newApproval);
	ctx.SumbmitChanges();

	newApproval.Location = ctx.Locations.Single(x=>x.Id == 2);	contractdoc.Approvalprocess.Remove(newApproval); // Property 'Delete on Null' for the relation between Contractdoc and Approvalprocess sets to True       
	ctx.SumbmitChanges(); // Exception: Test method MTests.ContractApprovalViewModelTest.TestRemoveApprovalAfterEdit threw exception: 
Devart.Data.Linq.LinqCommandExecutionException: Error on executing DbCommand. ---> Devart.Data.Oracle.OracleException: ORA-02291: integrity constraint (UD.FKAPPROVALPR530332) violated - parent key not found
        	
}
The generated script for the final SubmitChanges():

Code: Select all

UPDATE UD.APPROVALPROCESS SET CONTRACTDOCID = :p1, LOCATIONID = :p2 WHERE ID = :key1 AND CONTRACTDOCID = :chk1 AND LOCATIONID = :chk2 AND APPROVALSTATEID = :chk3 AND ENTERSTATEAT = :chk4 AND ((:nullchk5 = 1 AND MISSIVEID IS NULL) OR (MISSIVEID = :chk5)) AND ((:nullchk6 = 1 AND MISSIVEDATE IS NULL) OR (MISSIVEDATE = :chk6)) AND ((:nullchk7 = 1 AND DESCRIPTION IS NULL) OR (DESCRIPTION = :chk7))
-- p1: Input Number (Size = 0; DbType = Decimal) [0]
-- p2: Input Number (Size = 0; DbType = Decimal) [2]
-- key1: Input Number (Size = 0; DbType = Decimal) [10022]
-- chk1: Input Number (Size = 0; DbType = Decimal) [1]
-- chk2: Input Number (Size = 0; DbType = Decimal) [-1]
-- chk3: Input Number (Size = 0; DbType = Decimal) [-1]
-- chk4: Input Date (Size = 0; DbType = DateTime) [08.07.2011 0:00:00]
-- nullchk5: Input Integer (Size = 0; DbType = Int32) [1]
-- chk5: Input NVarChar (Size = 0; DbType = String) []
-- nullchk6: Input Integer (Size = 0; DbType = Int32) [1]
-- chk6: Input Date (Size = 0; DbType = DateTime) []
-- nullchk7: Input Integer (Size = 0; DbType = Int32) [1]
-- chk7: Input NVarChar (Size = 0; DbType = String) []
-- Context: Devart.Data.Oracle.Linq.Provider.OracleDataProvider Model: ao Build: 2.50.25.0

DELETE FROM ApprovalProcess
-- Context: Devart.Data.Oracle.Linq.Provider.OracleDataProvider Model: ao Build: 2.50.25.0

Posted: Fri 08 Jul 2011 08:18
by StanislavK
Thank you for the report, we have reproduced the problem. We will post here as soon as it is fixed.

Posted: Fri 07 Oct 2011 09:47
by StanislavK
The fix for this issue is available in the latest 3.0.5 build of LinqConnect. The new build can be downloaded from
http://www.devart.com/linqconnect/download.html
(the trial only) or from Registered Users' Area (for users with active subscription only).

For more information about the fixes and improvements available in LinqConnect 3.0.5, please refer to
http://www.devart.com/forums/viewtopic.php?t=22168