基于下面的伪代码,您能告诉我是否可以像这样做一些事情,或者在约束失败的情况下重新加载我的数据集会更好?
谢谢!
var myDataSet = new DataTypedDataset(); // the dataset has some tables with ParentChild and ForeightKey relationships
try{
myDataset.EnforceConstraints = false;
LoadDataset(meDataset); // some method that fills the schema by data that violates given schema constraints
myDataset.EnforceConstraints = true;
}
catch(ConstraintException ce){
LogConstraintException(ce);//some logging
myDataset.EnforceConstraints = false;
}
// suppose I have A = {1}, B = { {A=2, 2}, {A=1,2}}
try{
var aRow = myDataset.TableB.First().ARow;
}
catch(??/*What type of the exception will be here?*/ exception)
{
// hm... pitty
letsPlayFailureTollerantScenario(myDataset.TableB.First(), myDataset.TableA);
}
var rows = myDataset.TableA.GetBRows();
答案 0 :(得分:0)
经过一些测试后发现它在技术上是可行的。但说实话,如果任务在数据限制方面更加严格,我会更高兴,因为在这样的实施中找到一个错误并不是一个平安。