public void BeginLoadData()
{
long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.BeginLoadData|API> {0}", ObjectID);
try
{
if (_inDataLoad)
{
return;
}
_inDataLoad = true;
Debug.Assert(null == _loadIndex, "loadIndex should already be null");
_loadIndex = null;
// LoadDataRow may have been called before BeginLoadData and already
// initialized loadIndexwithOriginalAdded & loadIndexwithCurrentDeleted
_initialLoad = (Rows.Count == 0);
if (_initialLoad)
{
SuspendIndexEvents();
}
else
{
if (_primaryKey != null)
{
_loadIndex = _primaryKey.Key.GetSortIndex(DataViewRowState.OriginalRows);
}
if (_loadIndex != null)
{
_loadIndex.AddRef();
}
}
if (DataSet != null)
{
_savedEnforceConstraints = DataSet.EnforceConstraints;
DataSet.EnforceConstraints = false;
}
else
{
EnforceConstraints = false;
}
}
finally
{
DataCommonEventSource.Log.ExitScope(logScopeId);
}
}