有一些不明白它的意思.请高手详细说明一下原由.谢谢!
来源网址:http://support.microsoft.com/?scid=kb%3Bzh-cn%3B320301&x=11&y=15
protected static void OnDetailsRowUpdated( object sender, SqlRowUpdatedEventArgs args)
{
if (args.StatementType == StatementType.Insert )
{
// Do not allow the AcceptChanges to occur on this row.
args.Status = UpdateStatus.SkipCurrentRow; // 这里为什么要用UpdateStatus.SkipCurrentRow
// Get the current, actual primary key value so that you can plug it back
// in after you get the correct original value that was generated for the child row.
int currentkey = ( int )args.Row[ " OrderID " ];
// This is where you get a correct original value key that is stored to the child row.
// You pull the original, pseudo key value from the parent, plug it in as the child row's primary key
// field, and then accept changes on it. Specifically, this is why you turned off EnforceConstraints.
args.Row[ " OrderID " ] = args.Row.GetParentRow( " OrdDetail " )[ " OrderID " ,DataRowVersion.Original];
args.Row.AcceptChanges(); // 上面用了UpdateStatus.SkipCurrentRow,这里为什么还要AcceptChanges(),感觉矛盾.
// Store the actual primary key value in the foreign key column of the child row.
args.Row[ " OrderID " ] = currentkey; // 为什么又改回原来的值???
}
if (args.StatementType == StatementType.Delete )
args.Status = UpdateStatus.SkipCurrentRow; // 这里也不明白它的用意.