nbsp; { return; } } if (this.schemaTable == null) { this.SetupSchemaWithoutKeyInfo(action1, action2, gettingData, parentChapterColumn, parentChapterValue); } else { this.SetupSchemaWithKeyInfo(action1, action2, gettingData, parentChapterColumn, parentChapterValue); } } } //FillLoadDataRowChunk private int FillLoadDataRowChunk(SchemaMapping mapping, int startRecord, int maxRecords) { IDataReader reader1 = mapping.DataReader; while (0 < startRecord) //把DataReader调整到读startRecord记录的位置 { //如果DataReader的总的记录数小于startRecord,就返回0 if (!reader1.Read()) //其实在这里也可以看出要在DataReader中定位,只有去边历DataReader { //到这里我们也可以明白fill方法其实也是用DataReader一条条读出来的 return 0; } startRecord--; } int num1 = 0; if (0 >= maxRecords) { goto Label_0062; } bool flag1 = base.AcceptChangesDuringFill;//指示在Fill操作过程中,在将 AcceptChanges 添加到 DataTable 之后是否针对 DataRow 调用它。可以在msdn中的DataAdapter 类中查看 goto Label_0054; Label_002B: try { mapping.LoadDataRow(this.hasFillErrorHandler, flag1);//装载数据 num1++; } catch (Exception exception1) { this.FillErrorHandler(exception1, mapping.DataTable, mapping.DataValues); } Label_0054: if (num1 >= maxRecords)//如果载入的记录数已经满足条件,就退出,否则继续 { goto Label_006A; } if (reader1.Read())//继续读取数据 { goto Label_002B; } goto Label_006A; Label_0062: num1 = this.FillLoadDataRow(mapping); Label_006A: return num1; } 到这里fill方法大概就完了,其实看来fill方法就是首先创建映射,然后在用datareader把数据填充进来.其中我忽略了好多东西比如它的异常处理,还有好多细节,请各位朋友多多指教,在这里列出来也是和各位朋友探讨。
上一页 [1] [2] [3] [4] |