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()); } }
/// <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; }); }