在数据表上执行约束 [英] EnforceConstraint on Datatable

查看:99
本文介绍了在数据表上执行约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在数据集上是一个EnforceConstraints属性,指示是否应启用约束。尽管数据表也可以有约束,但我不能禁用数据表的约束。

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?

推荐答案

基本上,我所做的就是遍历约束素并删除它们。进行操作,然后在表上重新添加约束

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

这篇关于在数据表上执行约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆