public virtual void Load(IDataReader reader, LoadOption loadOption, FillErrorEventHandler errorHandler)
{
long logScopeId = DataCommonEventSource.Log.EnterScope("<ds.DataTable.Load|API> {0}, loadOption={1}", ObjectID, loadOption);
try
{
if (PrimaryKey.Length == 0)
{
DataTableReader dtReader = reader as DataTableReader;
if (dtReader != null && dtReader.CurrentDataTable == this)
{
return; // if not return, it will go to infinite loop
}
}
Common.LoadAdapter adapter = new Common.LoadAdapter();
adapter.FillLoadOption = loadOption;
adapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
if (null != errorHandler)
{
adapter.FillError += errorHandler;
}
adapter.FillFromReader(new DataTable[] { this }, reader, 0, 0);
if (!reader.IsClosed && !reader.NextResult())
{
reader.Close();
}
}
finally
{
DataCommonEventSource.Log.ExitScope(logScopeId);
}
}