开发者

How to merge only the missing rows

开发者 https://www.devze.com 2023-04-04 18:15 出处:网络
I have this code. However I got an exception in the merge line: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

I have this code.

However I got an exception in the merge line:

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

I would like a simple way, that it merges the missing rows only, if there are rows that already exist, it shouldn't tr开发者_C百科y to copy them

Thanks

// Init
UC010_WizardStepBusinessParkDataSet dataSet = new UC010_WizardStepBusinessParkDataSet();
View_BuildingModule_UC010_BusinessPark_Wizard_GetBusinessParkData vwBusPark = new View_BuildingModule_UC010_BusinessPark_Wizard_GetBusinessParkData();
View_BuildingModule_UC010_BusinessPark_Wizard_GetBusinessParkPortfolioManagerData vwBusParkPortfolioMngr = new View_BuildingModule_UC010_BusinessPark_Wizard_GetBusinessParkPortfolioManagerData();

vwBusPark.Where.BusinessParkID.Value = businessParkID;
vwBusParkPortfolioMngr.Where.BusinessParkID.Value = businessParkID;

if (vwBusPark.Query.Load())
    dataSet.BusinessPark.Merge(vwBusPark.toDataTable(), true, System.Data.MissingSchemaAction.Ignore);


Try merging with

vwBusPark.Except(dataSet.BusinessPark, DataRowComparer<YourRow>.Default)
0

精彩评论

暂无评论...
验证码 换一张
取 消