Exemple #1
0
        public FutureQueryOf(DetachedCriteria detachedCriteria, FutureQueryOptions options)
        {
            CriteriaBatch criteriaBatch = Batcher.Add(detachedCriteria);

            switch (options)
            {
            case FutureQueryOptions.None:
                criteriaBatch.OnRead <TEntity>(delegate(ICollection <TEntity> entities)
                {
                    results   = entities;
                    WasLoaded = true;
                });
                break;

            case FutureQueryOptions.WithTotalCount:
                criteriaBatch.OnRead <TEntity>(delegate(ICollection <TEntity> entities, int count)
                {
                    results    = entities;
                    totalCount = count;
                    WasLoaded  = true;
                });
                break;

            default:
                throw new NotSupportedException(options.ToString());
            }
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FutureValue{TEntity}"/> class.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="options">The options.</param>
        public FutureValue(object id, FutureValueOptions options)
        {
            this.id      = id;
            this.options = options;
            CriteriaBatch criteriaBatch = Batcher.Add(DetachedCriteria.For <TEntity>().Add(Restrictions.IdEq(id)));

            criteriaBatch.OnRead <TEntity>(delegate(TEntity entity)
            {
                value     = entity;
                WasLoaded = true;
            });
        }