0

根据下面的伪代码,您能否告诉我是否可以这样做,或者在约束失败的情况下重新加载我的数据集会更好?

谢谢!

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(); 
4

1 回答 1

0

因此,经过一些测试,事实证明这在技术上是可行的。但老实说,如果任务在数据约束方面更严格,我会更高兴,因为在这样的实现下发现错误并不是一件容易的事。

于 2013-11-18T21:39:31.317 回答