Hi,
I'm trying to figure out this exception I have begun to get when trying to save an entitycollection using the adapter method.
The database model is getting rather complex, so I can not pin it out in detail here.
The exception is as follows:
"An exception was caught during the execution of an action query: Cannot insert the value NULL into column 'CaseId', table 'PManagement.dbo.Case2TurbineUnitType'; column does not allow nulls."
What I'm trying to do is that I have an entity called "Case" (CaseId being the PK) and a collection attached to that called "Case2TurbineUnitType" (referencing Case by CaseId). I have coupled the two together when creating new objects at runtime by doing somthing like this:
dim c2tute as new Case2TurbineUnitTypeEntity()
'
' setting various properties
'
oCase.Case2TurbineUnitType.Add(c2tute) 'oCase being the runtime object of Case
using daa as new dataaccessadapter(true)
daa.saveentitycollection(oCase.Case2TurbineUnitType, true, true)
daa.closeconnection()
end using
When trying to use a dataaccessadapter to save the Case2TurbineUnitType collection, I get the above exception. The program fails at the SaveEntityCollection line.
While debugging the project I have noticed that everything seems to be in order object wise, that CaseId is set correctly and the objects are in the correct structure.
One important thing to note is that I have circular references in the database, which means you can go round in circles from Case via Case2TurbineUnitType and some other tables and getting back to the very same Case object again. This is the case when the saveentitycollection is being run. Is this giving any problems LLBL wise?
If it is the case, is there then any way to say to LLBL to only save 2 or 3 levels deep in the object hierarchy when saving recursively? This would otherwise be an idea for future development.
I hope you can help me out here, because I'm getting crazier by the moment :-)