c# - DataTable merge treats duplicate PK as update rather than erroring -
i trying merge 2 datatables - 1 representing current data, , 1 representing proposed insertions data.
these tables have same schema, both simple, user-provided primary key string.
what i'd like is, if proposed insertion row has key present in current data, error should thrown. however, proposed addition gets merged proposed alteration existing row, not want.
my current code along lines of
currentdata.enforceconstraints = false; currentdata.merge(additions); currentdata.enforceconstraints = true; where i'm merging whole datasets, not datatables. hoping error on enforceconstraints = true line, don't.
i tried using diffgrams, had same problem - duplicate insertions treated modifications.
is there way merge set of insertions dataset , have duplicate pks treated error rather update?
similarly, since modified datarows remember original values, i'd hope merging modified row original values don't match target row's current values throw exception too.
isn't unique flag used purpose? understanding merge merge rows based on primary key.
Comments
Post a Comment