下面是reflector看到的代码, 这里的实现看的我一头雾水, 它应该是从socket取得来的数据吧, socket ---------(中间过程)--------------> SqlDataReader.GetString(...)取数据
这个中间过程怎么样的?Can someone explain more? Thanks in advance.
public override bool Read()
{
return this.ReadInternal(true);
} private bool ReadInternal(bool setTimeout)
{
bool flag;
SqlStatistics statistics = null;
IntPtr ptr;
Bid.ScopeEnter(out ptr, "<sc.SqlDataReader.Read|API> %d#", this.ObjectID);
RuntimeHelpers.PrepareConstrainedRegions();
try
{
statistics = SqlStatistics.StartTimer(this.Statistics);
if (this._parser == null)
{
goto Label_017B;
}
if (setTimeout)
{
this.SetTimeout();
}
if (this._dataReady)
{
this.CleanPartialRead();
}
this._dataReady = false;
SqlBuffer.Clear(this._data);
this._nextColumnHeaderToRead = 0;
this._nextColumnDataToRead = 0;
this._columnDataBytesRemaining = -1L;
if (this._haltRead)
{
goto Label_016A;
}
if (this.HasMoreRows())
{
while (this._stateObj._pendingData)
{
if (this._altRowStatus != ALTROWSTATUS.AltRow)
{
this._dataReady = this._parser.Run(RunBehavior.ReturnImmediately, this._command, this, null, this._stateObj);
if (!this._dataReady)
{
continue;
}
}
else
{
this._altRowStatus = ALTROWSTATUS.Done;
this._dataReady = true;
}
break;
}
if (this._dataReady)
{
this._haltRead = this.IsCommandBehavior(CommandBehavior.SingleRow);
return true;
}
}
if (!this._stateObj._pendingData)
{
this.CloseInternal(false);
}
goto Label_018E;
Label_010E:
this._dataReady = this._parser.Run(RunBehavior.ReturnImmediately, this._command, this, null, this._stateObj);
Label_012E:
if (this._stateObj._pendingData && !this._dataReady)
{
goto Label_010E;
}
if (this._dataReady)
{
this.CleanPartialRead();
}
this._dataReady = false;
SqlBuffer.Clear(this._data);
this._nextColumnHeaderToRead = 0;
Label_016A:
if (this.HasMoreRows())
{
goto Label_012E;
}
this._haltRead = false;
goto Label_018E;
Label_017B:
if (this.IsClosed)
{
throw ADP.DataReaderClosed("Read");
}
Label_018E:
return false;
}
catch (OutOfMemoryException exception3)
{
this._isClosed = true;
SqlConnection connection3 = this._connection;
if (connection3 != null)
{
connection3.Abort(exception3);
}
throw;
}
catch (StackOverflowException exception2)
{
this._isClosed = true;
SqlConnection connection2 = this._connection;
if (connection2 != null)
{
connection2.Abort(exception2);
}
throw;
}
catch (ThreadAbortException exception)
{
this._isClosed = true;
SqlConnection connection = this._connection;
if (connection != null)
{
connection.Abort(exception);
}
throw;
}
finally
{
SqlStatistics.StopTimer(statistics);
Bid.ScopeLeave(ref ptr);
}
return flag;
}
解决方案 »
- c#如何模拟键盘中的组合键?
- (Joomla)PHP一点没接触过,现在有问题。麻烦进来帮一下,会不会是另一回事。
- Access区的人告诉我Access不能用SQL语句修改表名和字段名,要用什么ADOX,那么在C#.NET里应用什么?怎么实现?
- 关于WEB页面设计
- 关于treeview选子节点与选父节点问题.....
- [WINFORM]关于客户端和服务端编程。为什么要分客户端和服务端?每一个客户端连接SQL后进行操作,要服务端干什么呢?
- 大家进来看看,有这个属性么??
- C#中的自建一个Main类,其Constructor难道不可以和Main()函数同名吗?
- 长沙三恩科技招聘.net开发人员
- 如何在在程序运行过程中修改TableAdapter的SELECTCommand
- vs.net2010中在项目属性中改变目标框架,生成失败怎么解决呢?
- 为什么在foreach循环中不能修改值类型实例的成员呢?
{
bool flag;
SqlStatistics statistics = null;
IntPtr ptr;
Bid.ScopeEnter(out ptr, "<sc.SqlDataReader.Read|API> %d#", this.ObjectID);
RuntimeHelpers.PrepareConstrainedRegions();
try
{
statistics = SqlStatistics.StartTimer(this.Statistics);
if (this._parser == null)
{
if (this.IsClosed)
{
throw ADP.DataReaderClosed("Read");
}
return false;
}
if (setTimeout)
{
this.SetTimeout();
}
//清除数据、初始化数据
if (this._dataReady)
{
this.CleanPartialRead();
}
this._dataReady = false;
SqlBuffer.Clear(this._data);
this._nextColumnHeaderToRead = 0;
this._nextColumnDataToRead = 0;
this._columnDataBytesRemaining = -1L;
//如果是停止读取(已经读到最后一条记录了或者EOF)了
if (this._haltRead)
{
if (this.HasMoreRows())
{
while (this._stateObj._pendingData && !this._dataReady) //注意此处变为循环了,运行到第一条记录处或者BOF
{
this._dataReady = this._parser.Run(RunBehavior.ReturnImmediately, this._command, this, null, this._stateObj);
}
if (this._dataReady)
{
this.CleanPartialRead();
}
this._dataReady = false;
SqlBuffer.Clear(this._data);
this._nextColumnHeaderToRead = 0;
}
this._haltRead = false;
return false;
} if (this.HasMoreRows())
{
while (this._stateObj._pendingData)
{
if (this._altRowStatus != ALTROWSTATUS.AltRow)
{
this._dataReady = this._parser.Run(RunBehavior.ReturnImmediately, this._command, this, null, this._stateObj);
if (!this._dataReady)
{
continue;
}
}
else
{
this._altRowStatus = ALTROWSTATUS.Done;
this._dataReady = true;
}
break;
}
if (this._dataReady)
{
this._haltRead = this.IsCommandBehavior(CommandBehavior.SingleRow);
return true;
}
}
if (!this._stateObj._pendingData)
{
this.CloseInternal(false);
}
return false;
}
catch (OutOfMemoryException exception3)
{
this._isClosed = true;
SqlConnection connection3 = this._connection;
if (connection3 != null)
{
connection3.Abort(exception3);
}
throw;
}
catch (StackOverflowException exception2)
{
this._isClosed = true;
SqlConnection connection2 = this._connection;
if (connection2 != null)
{
connection2.Abort(exception2);
}
throw;
}
catch (ThreadAbortException exception)
{
this._isClosed = true;
SqlConnection connection = this._connection;
if (connection != null)
{
connection.Abort(exception);
}
throw;
}
finally
{
SqlStatistics.StopTimer(statistics);
Bid.ScopeLeave(ref ptr);
}
return flag;
}
二是正常读取下一条记录,填充数据到this._data,然后返回true