Esempio n. 1
0
        /// <summary>
        /// 对实体集合进行批量操作。
        /// </summary>
        /// <param name="instances">要操作的实体序列。</param>
        /// <param name="fnOperation">实体操作表达式,权提供 Insert、Update 和 Delete 操作。</param>
        /// <returns>影响的实体数。</returns>
        public int Batch(IEnumerable <TEntity> instances, Expression <Func <IRepository <TEntity>, TEntity, int> > fnOperation)
        {
            var operateName = OperateFinder.Find(fnOperation);
            var eventType   = GetBeforeEventType(operateName);

            instances.ForEach(s => EntityPersistentSubscribePublisher.RaiseEvent(s, eventType));

            return(repositoryProxy.Batch(instances, fnOperation));
        }
Esempio n. 2
0
        /// <summary>
        /// 对实体集合进行批量操作。
        /// </summary>
        /// <param name="instances">要操作的实体序列。</param>
        /// <param name="fnOperation">实体操作表达式,权提供 Insert、Update 和 Delete 操作。</param>
        /// <param name="batchOpt"></param>
        /// <returns>影响的实体数。</returns>
        public virtual int Batch(IEnumerable <TEntity> instances, Expression <Func <IRepository <TEntity>, TEntity, int> > fnOperation, BatchOperateOptions batchOpt = null)
        {
            if (instances.IsNullOrEmpty())
            {
                return(-1);
            }

            var operateName = OperateFinder.Find(fnOperation);
            var eventType   = GetEventType(operateName);

            return(_subMgr.OnBatch <TEntity, int>(_contextService.ServiceProvider, _options.NotifyEvents,
                                                  instances.Cast <IEntity>(), eventType,
                                                  () => _repositoryProxy.Batch(instances, fnOperation, batchOpt)));
        }
Esempio n. 3
0
        /// <summary>
        /// 对实体集合进行批量操作。
        /// </summary>
        /// <param name="instances">要操作的实体序列。</param>
        /// <param name="fnOperation">实体操作表达式,权提供 Insert、Update 和 Delete 操作。</param>
        /// <returns>影响的实体数。</returns>
        public int Batch(IEnumerable <TEntity> instances, Expression <Func <IRepository <TEntity>, TEntity, int> > fnOperation)
        {
            if (instances.IsNullOrEmpty())
            {
                return(-1);
            }

            var operateName = OperateFinder.Find(fnOperation);
            var eventType   = GetBeforeEventType(operateName);

            int func() => repositoryProxy.Batch(instances, fnOperation);

            return(options.NotifyEvents ?
                   EntityPersistentSubscribeManager.OnBatch(instances.Cast <IEntity>(), eventType, func) :
                   func());
        }
Esempio n. 4
0
        /// <summary>
        /// 对实体集合进行批量操作。
        /// </summary>
        /// <param name="instances">要操作的实体序列。</param>
        /// <param name="fnOperation">实体操作表达式,权提供 Insert、Update 和 Delete 操作。</param>
        /// <returns>影响的实体数。</returns>
        public int Batch(IEnumerable <TEntity> instances, Expression <Func <IRepository <TEntity>, TEntity, int> > fnOperation)
        {
            var operateName = OperateFinder.Find(fnOperation);
            var eventType   = GetBeforeEventType(operateName);

            return(EntityPersistentSubscribePublisher.OnBatch(instances.Cast <IEntity>(), eventType, () => repositoryProxy.Batch(instances, fnOperation)));
        }