I have three objects: Staff, Project, and ProjectTeam. Project team looks like so:
Code:
CREATE TABLE [dbo].[ut_ProjTeam](
[ptKey] [bigint] IDENTITY(1,1) NOT NULL,
[ptProjKey] [int] NOT NULL,
[ptStKey] [smallint] NULL,
[ptStRole] [smallint] NOT NULL
)
Essentially this table is part of a many-to-many relationship between the project (ptProjKey) and the staff member (ptStKey).
I've created this table a a separate business object so I can get to the ptStRole field. I can add items just fine it is when I delete that things become problematic. Either I get :
Quote:
deleted object would be re-saved by cascade
Or
Quote:
Cannot insert the value NULL into column 'ptProjKey',
I'm trying to remove the reference to the ProjectTeam entry from the Project and Staff objects BEFORE I do the delete, but this doesn't seem to work. It appears that when I try to remove the reference with a call like this:
Code:
projTeamToRemove.Project.RemoveFromProjectTeam(projTeamToRemove);
the database tries to do an UPDATE first, which of course will fail since the foreign keys can't be null.
Solutions? Work-around? Thoughts?
Thanks
Jack