示例#1
0
        internal ObjectReader(Internals.Context context, ObjectQuery objectQuery, bool firstLevel)
        {
            this.context    = context;
            this.firstLevel = firstLevel;
            this.objectType = objectQuery.ObjectType;
            this.pageIndex  = objectQuery.PageIndex;
            this.hasEvents  = context.Mappings[this.objectType.ToString()].HasEvents;

            Internals.Commands commands = context.Mappings.Commands(this.objectType.ToString());
            if (objectQuery.PageSize > 0 && !objectQuery.SkipCounts)
            {
                string selectCount = commands.RecordCount(objectQuery.WhereClause);
                this.totalCount = int.Parse(context.Connection.GetScalarValue(this.objectType, CommandInfo.GetCount, selectCount).ToString());
                double pages = (double)(1 + (this.totalCount - 1) / objectQuery.PageSize);
                this.pageCount = int.Parse(Math.Floor(pages).ToString());
            }
            this.data      = context.Connection.GetDataReader(this.objectType, CommandInfo.Select, commands.Select(objectQuery));
            this.firstRead = true;
            if (this.data != null)
            {
                this.hasObjects = this.data.Read();
            }
            if (!this.hasObjects)
            {
                this.Close();
            }
        }
示例#2
0
        // Includes GetObjectCount by Ken Muse (http://www.MomentsFromImpact.com)
        public int GetObjectCount(ObjectQuery objectQuery)
        {
            Commands commands = this.Mappings.Commands(objectQuery.ObjectType);

            // Oracle returns decimals so cast to int failed
            return(Convert.ToInt32(this.Connection.GetScalarValue(objectQuery.ObjectType, CommandInfo.GetCount, commands.RecordCount(objectQuery.WhereClause))));
        }