예제 #1
0
        public void BufferData(int highestRow)
        {
            if (!IsBufferMode)
            {
                var isStop = false;
                while (CachedResult.Rows.Count < highestRow && !isStop)
                {
                    isStop = true;
                    DataRow row = null;
                    if (DataReader != null && DataReader.Read())
                    {
                        row = CachedResult.NewRow();
                        CachedResult.Rows.Add(row);

                        var count = DataReader.FieldCount;
                        for (var i = 0; i < count; i++)
                        {
                            row[DataReader.GetName(i)] = DataReader.GetValue(i);
                        }

                        isStop = false;
                    }

                    if (DataReader2 != null && DataReader2.Read())
                    {
                        if (row == null)
                        {
                            row = CachedResult.NewRow();
                            CachedResult.Rows.Add(row);
                        }

                        var count = DataReader2.FieldCount;
                        for (var i = 0; i < count; i++)
                        {
                            row[DataReader2.GetName(i)] = DataReader2.GetValue(i);
                        }

                        isStop = false;
                    }
                }
            }
        }
예제 #2
0
        public void BufferData(int highestRow)
        {
            if (!IsBufferMode)
            {
                var isStop = false;
                if (DataReader2 == null)
                {
                    while (CachedResult.Rows.Count < highestRow && !isStop)
                    {
                        isStop = true;
                        DataRow row = null;
                        if (DataReader != null && DataReader.Read())
                        {
                            row = CachedResult.NewRow();
                            CachedResult.Rows.Add(row);

                            var count = DataReader.FieldCount;
                            for (var i = 0; i < count; i++)
                            {
                                row[DataReader.GetName(i)] = DataReader.GetValue(i);
                            }
                            isStop = false;
                        }

                        if (DataReader2 != null && DataReader2.Read())
                        {
                            if (row == null)
                            {
                                row = CachedResult.NewRow();
                                CachedResult.Rows.Add(row);
                            }

                            var count = DataReader2.FieldCount;
                            for (var i = 0; i < count; i++)
                            {
                                row[DataReader2.GetName(i)] = DataReader2.GetValue(i);
                            }

                            isStop = false;
                        }
                    }
                }
                else
                {
                    string primaryKey = null;
                    for (var i = 0; i < DataReader.FieldCount; i++)
                    {
                        for (var j = 0; j < DataReader2.FieldCount; j++)
                        {
                            if (DataReader.GetName(i) == DataReader2.GetName(j))
                            {
                                primaryKey = DataReader.GetName(i);
                            }
                        }
                    }

                    while (CachedResult.Rows.Count < highestRow && !isStop)
                    {
                        isStop = true;
                        DataRow row = null;
                        if (DataReader != null && DataReader.Read())
                        {
                            row = CachedResult.NewRow();
                            CachedResult.Rows.Add(row);

                            var count = DataReader.FieldCount;
                            for (var i = 0; i < count; i++)
                            {
                                row[DataReader.GetName(i)] = DataReader.GetValue(i);
                            }
                            isStop = false;
                        }
                    }
                    DataTable dt1 = CachedResult.Copy();
                    CachedResult.Clear();
                    isStop = false;
                    while (CachedResult.Rows.Count < highestRow && !isStop)
                    {
                        isStop = true;
                        DataRow row = null;
                        if (DataReader2 != null && DataReader2.Read())
                        {
                            if (row == null)
                            {
                                row = CachedResult.NewRow();
                                CachedResult.Rows.Add(row);
                            }

                            var count = DataReader2.FieldCount;
                            for (var i = 0; i < count; i++)
                            {
                                row[DataReader2.GetName(i)] = DataReader2.GetValue(i);
                            }

                            isStop = false;
                        }
                    }
                    DataTable dt2 = CachedResult.Copy();
                    CachedResult.Clear();
                    var tables = new DataTable[] { dt1, dt2 };
                    CachedResult = MergeAll(tables.ToList(), primaryKey);
                }
            }
        }