views:

14

answers:

1

There's a column on one of my tables that's being updated by various INSERT/DELETE triggers in my database - the triggers perform some calculation based on the contents of linked tables and store the result in a column on the base table for easier querying, etc.

Linq-to-SQL is throwing a ChangeConflictException when I try to update these tables - presumably because the trigger is modifying this column and so L2S thinks there's a data conflict.

The exact behaviour I'm looking for is as follows:

  • L2S should retrieve this column value when retrieving an object
  • L2S should ignore changes to this column value - changes made in code should not be persisted to the DB
  • Conflicts on saving should be ignored.
  • (if possible) the latest value should be retrieved from the DB following any insert/update operation - but I can live without this one if it's difficult.

Can anyone help me implement this behaviour in Linq-to-SQL?

Thanks,

Dylan

A: 

You should configure the columns as auto generated (just as you do with primary keys) in he LINQ to SQL designer. This will prevent these conflicts.

Steven