示例#1
0
 /// <summary>
 /// Removes the specified id.
 /// </summary>
 /// <param name="id">The id.</param>
 public void Remove(TId id)
 {
     _mongoHelper.Repository.GetCollection <TEntity>(_collection)
     .FindAndRemove(QueryWrapper.Create(new { _id = id }), SortBy.Null);
 }
示例#2
0
 /// <summary>
 /// Removes the specified spec.
 /// </summary>
 /// <param name="spec">The spec.</param>
 public void Remove(object spec)
 {
     _mongoHelper.Repository.GetCollection <TEntity>(_collection).Remove(QueryWrapper.Create(spec));
 }
示例#3
0
 /// <summary>
 /// Finds the specified spec.
 /// </summary>
 /// <param name="spec">The spec.</param>
 /// <param name="orderby">The orderby.</param>
 /// <param name="limit">The limit.</param>
 /// <param name="skip">The skip.</param>
 /// <returns></returns>
 public IEnumerable <TEntity> Find(object spec, object orderby, int limit, int skip)
 {
     using (_mongoHelper.Repository.RequestStart())
     {
         return(_mongoHelper.Repository.GetCollection <TEntity>(_collection).Find(QueryWrapper.Create(spec))
                .SetSortOrder(SortByWrapper.Create(orderby))
                .SetSkip(skip)
                .SetLimit(limit)
                .ToList());
     }
 }
示例#4
0
 /// <summary>
 /// Finds the count.
 /// </summary>
 /// <param name="spec">The spec.</param>
 /// <returns></returns>
 public long Count(object spec)
 {
     return(_mongoHelper.Repository.GetCollection <TEntity>(_collection).Count(QueryWrapper.Create(spec)));
 }
示例#5
0
 /// <summary>
 /// Finds the specified spec.
 /// </summary>
 /// <param name="spec">The spec.</param>
 /// <returns></returns>
 public IEnumerable <TEntity> Find(object spec)
 {
     using (_mongoHelper.Repository.RequestStart())
     {
         return(_mongoHelper.Repository.GetCollection <TEntity>(_collection).Find(QueryWrapper.Create(spec)).ToList());
     }
 }
示例#6
0
 /// <summary>
 /// Finds the one.
 /// </summary>
 /// <param name="spec">The spec.</param>
 /// <returns></returns>
 public TEntity FindOne(object spec)
 {
     using (_mongoHelper.Repository.RequestStart())
     {
         return(_mongoHelper.Repository.GetCollection <TEntity>(_collection).FindOne(QueryWrapper.Create(spec)));
     }
 }