logo       

Merging DataSet (Added and Unchanged): msg#00330

windows.devel.dotnet.winforms

Subject: Merging DataSet (Added and Unchanged)

The docs state

"When merging a new source DataSet into the target, any source rows with a
DataRowState value of Unchanged, Modified, or Deleted, are matched to target
rows with the same primary key values. Source rows with a DataRowState value
of Added are matched to new target rows with the same primary key values as
the new source rows."

This part:

"Source rows with a DataRowState value of Added are matched to new target
rows with the same primary key values as the new source rows."

h

as always confused me. Our app sends an Added DataRow to our DAL (we call
the client Dataset's GetChanges method and send this smaller DataSet across
the wire).

Our DAL does the insert. A primary key is returned as part of the insert.
The DataRow now has the PrimaryKey value and is now marked as Unchanged.
The client 'Added' DataRow does not have the PrimaryKey though. It is
storing a dummy PrimaryKey.

So, we return to the client with an Unchanged DataRow that is storing the
correct PrimaryKey from sql server.

So, how can this 'match' work? The Source DataRow is marked as Added.
However, the returning DataRow's PrimaryKey will never match.

What we do now, is just prior to calling Merge, we remove all Added DataRows
from the client DataSet. The we call Merge.

This works, but seems like extra overhead to me.

Greg Robinson
Custom Data Systems, Inc.
www.cds-am.net



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise