Пример #1
0
 public List <TField> Distinct <TField>(Expression <Func <TEntity, TField> > fieldExp, FilterDefinition <TEntity> filter, ReadPreference readPreference = null)
 {
     if (filter == null)
     {
         filter = Filter.Empty;
     }
     return(IAsyncCursorExtensions.ToList <TField>(IMongoCollectionExtensions.Distinct <TEntity, TField>(GetCollection(readPreference), fieldExp, filter, null)));
 }
Пример #2
0
 public List <TField> Distinct <TField>(FieldDefinition <TEntity, TField> field, FilterDefinition <TEntity> filter, ReadPreference readPreference = null)
 {
     if (filter == null)
     {
         filter = Filter.Empty;
     }
     return(IAsyncCursorExtensions.ToList(GetCollection(readPreference).Distinct(field, filter, null)));
 }
Пример #3
0
        public async Task <List <TEntity> > GetListAsync(FilterDefinition <TEntity> filter, ProjectionDefinition <TEntity, TEntity> projection = null, SortDefinition <TEntity> sort = null, int limit = 0, int skip = 0, BsonValue hint = null, ReadPreference readPreference = null)
        {
            if (filter == null)
            {
                filter = Filter.Empty;
            }
            FindOptions <TEntity, TEntity> options = CreateFindOptions(projection, sort, limit, skip, hint);

            return(await IAsyncCursorExtensions.ToListAsync(await GetCollection(readPreference).FindAsync(filter, options)));
        }
Пример #4
0
        public async Task <TEntity> GetAsync(FilterDefinition <TEntity> filter, ProjectionDefinition <TEntity, TEntity> projection = null, SortDefinition <TEntity> sort = null, BsonValue hint = null, ReadPreference readPreference = null)
        {
            if (filter == null)
            {
                filter = Filter.Empty;
            }
            FindOptions <TEntity, TEntity> options = CreateFindOptions(projection, sort, 1, 0, hint);

            return(await IAsyncCursorExtensions.FirstOrDefaultAsync(await GetCollection(readPreference).FindAsync(filter, options)));
        }
Пример #5
0
        /// <summary>
        /// 根据条件返回评论列表(不分页)
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <returns></returns>
        public async Task <List <UserComm> > QueryUserCommListAsync(UserCommQuery query)
        {
            try
            {
                if (query == null)
                {
                    _log.Error("query is not null");
                    return(null);
                }
                var express = BuildQuery(query);

                var ret = await _mongoRespository.QueryListAsync(express);

                var resultList = await IAsyncCursorExtensions.ToListAsync(ret);

                return(resultList);
            }
            catch (Exception ex)
            {
                _log.Error("QueryUserCommListAsync method error:" + ex);
                throw;
            }
        }