示例#1
0
        /// <summary>
        /// Updates the specified id.
        /// </summary>
        /// <param name="spec">The spec.</param>
        /// <param name="action">The action.</param>
        public void UpdateAll(object spec, Action <IModifierExpression <TEntity, TId> > action)
        {
            var modifier = new ModifierExpression <TEntity, TId>();

            action(modifier);

            _mongoHelper.Repository.GetCollection <TEntity>(_collection)
            .Update(QueryWrapper.Create(spec), modifier.GetUpdateBuilder(), UpdateFlags.Multi);
        }
示例#2
0
        /// <summary>
        /// Updates the specified id.
        /// </summary>
        /// <param name="spec">The spec.</param>
        /// <param name="action">The action.</param>
        /// <param name="createIfNew">if set to <c>true</c> [create if new].</param>
        public void Update(object spec, Action <IModifierExpression <TEntity, TId> > action, bool createIfNew = false)
        {
            var modifier = new ModifierExpression <TEntity, TId>();

            action(modifier);

            _mongoHelper.Repository.GetCollection <TEntity>(_collection)
            .Update(QueryWrapper.Create(spec), modifier.GetUpdateBuilder(), createIfNew ? UpdateFlags.Upsert : UpdateFlags.None);
        }
示例#3
0
        /// <summary>
        /// Finds the specified func.
        /// </summary>
        /// <param name="spec">The spec.</param>
        /// <param name="action">The action.</param>
        /// <param name="createIfNew"> </param>
        /// <param name="getUpdatedEntity"> </param>
        public virtual TEntity FindAndModify(object spec, Action <IModifierExpression <TEntity, TId> > action, bool createIfNew = false, bool getUpdatedEntity = false)
        {
            var modifier = new ModifierExpression <TEntity, TId>();

            action(modifier);

            return(_mongoHelper.Repository.GetCollection <TEntity>(_collection)
                   .FindAndModify(QueryWrapper.Create(spec),
                                  SortBy.Null,
                                  modifier.GetUpdateBuilder(), getUpdatedEntity, createIfNew)
                   .GetModifiedDocumentAs <TEntity>());
        }