开发者

How do I get Linq-to-SQL to ignore columns that are modified by INSERT triggers?

开发者 https://www.devze.com 2023-01-17 02:15 出处:网络
There\'s a column on one of my tables that\'s being 开发者_JAVA百科updated by various INSERT/DELETE triggers in my database - the triggers perform some calculation based on the contents of linked tabl

There's a column on one of my tables that's being 开发者_JAVA百科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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消