Search code examples
c#datatablestrongly-typed-datasetconstraints

EnforceConstraint on Datatable


On a dataset is a EnforceConstraints property indicating whether the constraints should be enabled. Althought a datatable also can have constraints i cannot disable the constraints for a datatable.

My case is that I have datatable which i use in memory with a uniqueconstraint on one of the columns. Sometimes i want to temporarily disable the unique constraint. How can I do this? The only thing I came up with is removing and re-adding the constraint. Is there a better way?


Solution

  • Basically what i did is loop through the contrains and remove them. Do the action and re-add the constraints on the table