Exemplo n.º 1
0
        private void DataLoadDirect(IProcessor ip, Type returnType, SqlStatement sql, bool useIndex, bool noLazy)
        {
            long startIndex = sql.StartIndex;
            long endIndex   = sql.EndIndex;

            if (Provider.Dialect.SupportsRangeStartIndex && endIndex > 0)
            {
                endIndex   = endIndex - startIndex + 1;
                startIndex = 1;
            }
            var creator = ModelCreator.GetCreator(returnType, useIndex, noLazy);

            Provider.ExecuteDataReader(sql, returnType, delegate(IDataReader dr)
            {
                int count = 0;
                while (dr.Read())
                {
                    count++;
                    if (count >= startIndex)
                    {
                        object di = creator.CreateObject(dr);
                        if (!ip.Process(di))
                        {
                            break;
                        }
                    }
                    if (endIndex > 0 && count >= endIndex)
                    {
                        break;
                    }
                }
            });
        }