Esempio n. 1
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;
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Initialize a new instance of FutureValue with identity value to look for.
        /// </summary>
        /// <param name="id"></param>
        /// <param name="options"></param>
        public FutureValue(object id, FutureValueOptions options)
        {
            id.ShouldNotBeNull("id");

            _id      = id;
            _options = options;

            if (IsDebugEnabled)
            {
                log.Debug("CriteriaBatch 를 통해 Entity조회를 예약했습니다. type=[{0}], id=[{1}], options=[{2}]",
                          typeof(T).FullName, id, options);
            }

            var criteriaBatch = FutureBase.Batcher.Add(DetachedCriteria.For <T>().Add(Restrictions.IdEq(id)));

            criteriaBatch.OnRead((T entity) => {
                _value   = entity;
                IsLoaded = true;
            });
        }