2

What property needs to be set so that when i call DataContext.Submit changes or UpdateAll, the contraints that are there needs to be overlooked. Constraints such as foreign key and also primary key contraints

Joy
  • 21
  • 2
  • As marc_s pointed out, this is outside the hands of LINQ-TO-SQL itself (SQL Server, with only *immediate constraints*, will violently reject such model integrity violations!). If there are more details provided as to what the specific task is -- if such can be done -- then there will likely be better solutions/work-abouts posted. Happy coding. –  Jun 25 '11 at 07:16

1 Answers1

0

You cannot just "switch off" all those checks from outside the database. You can disable it on the database when needed, e.g. when you want to bulk insert a large number of rows.

But a database access component like Linq-To-SQL cannot (and should not!) just turn those checks off. Those checks are there for a good reason!

What reason do you have to want to turn off those checks?? What are you trying to accomplish? If you explain a bit more, maybe the community can help you find ways to accomplish what you want to do without those dirty tricks....

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • how abt disabling so that updates check is turnoff? Concurrency check. Something in lines of ConflictMode Enumeration. – Joy Jun 25 '11 at 05:30
  • @Joy: same thing: those checks are there **for a reason** - you need to respect those! You cannot and should not disable those from your data access code (only from within the database). What are you trying to do - why are those constraints a problem for you?? – marc_s Jun 25 '11 at 05:31
  • 1
    Wouldn't it be nice in cases if SQL Server allowed constraints could be handily *deferred* until the COMMIT (as provisioned by the SQL specification)? ;-) It would sure make some "dumb" multi-table batch imports simpler (and circular references possible) ... anyway, the general "work-about" I have seen is *disable* (ick!) and then *re-enable* said constraints, which is a very poor solution to trying to get such semantics. Sometimes NULLABLE fields are used to "get around" the circular dependency issue. –  Jun 25 '11 at 06:32
  • @pst: yes, that would be great - but that's not possible right now. My main point is: those constraints are in the database for a good reason - you shouldn't invest lots of effort in trying to **circumvent** those - you should learn how to honor them and write your program accordingly. – marc_s Jun 25 '11 at 08:07
  • 1
    I completely agree and you already have your +1 ;-) Any general solutions for "correct ordering" or is it generally just a one-off case issue use selectly-timed `SubmitChanges`? –  Jun 25 '11 at 08:37
  • If they can be turned off, then explaining how would be a good answer. – Chalky May 24 '17 at 09:08