MS SQL Server 2008 Check Constraint, and LINQ-To-SQL -


This is a difficult question for the word ... so bear with me.

I have two tables in my database, [items] and [AssignedProperty] . [AssignedProperty] The child's parents are in the relationship with the [Item] . So it basically uses an item IDID field and a foreign key relationship. [AssignedProperty] also has a similar relation with the second table named [property] , and its own primary key, Assign Property ID It creates a lot of relationships, though I have an obstacle, which determines that a [AssignedProperty] is not a duplicate of item IDID and property ID in the same record May be Therefore, one can be one of only one [property] in [code] [item] .

It works well, but with LINQ-to-SQL, this one I think is the sequence of execution on the issue issue that fights with this obstacle.

To generate this error, I use a [item] sql in my application using LINQ-to-0. I then select a [[Code> Assign Property] object from the [AssignedProperties] collection of the object and delete it. Then I create a new [AssignedProperty] object with the exact same item IDID and property ID which I just removed, and added it back to the archive. When I call [SubmitChanges] on the DataContext, it flagged me on the barrier if there was previously the old [AssignedProperty] record removed, no reason That the new should produce that error. It seems that it is trying to insert the new [AssignedProperty] before removing the old one.

How should I fix this, and in my database or in my app? 94% is annoying me, and the answer to that is in the original post's comment. I TIA

So, that's just because I can really choose an answer.


Comments