2013-08-28 69 views
0

基於下面的僞代碼,請告訴我是否可以這樣做,或者在約束失敗的情況下重新加載我的數據集會更好?C#數據集中的EnforceConstraints之後的ConstraintException

謝謝!

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

所以經過一些測試後發現它在技術上是可行的。但說實話,如果在數據限制方面任務更嚴格,我會更高興,因爲在這樣的實施下找到一個錯誤並不是一種平安。

相關問題