Esempio n. 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();
            }
        }
Esempio n. 2
0
		private Instance(Context context, object entityObject) {
			this.context = context;
			string type = entityObject.GetType().ToString();
			this.entity = this.context.Mappings[type];
			this.commands = this.context.Mappings.Commands(type);
			this.instance = new WeakReference(entityObject);
			this.values = new object[this.entity.FieldCount];
		}