コード例 #1
0
ファイル: MongoQuery.cs プロジェクト: hugoware/CSMongo
 /// <summary>
 /// Selects only one document with the provided parameters
 /// </summary>
 public MongoDocument SelectOne(int skip, QueryOptionTypes options, params string[] fields)
 {
     return this.Select(skip, 1, options, fields).FirstOrDefault();
 }
コード例 #2
0
ファイル: MongoQuery.cs プロジェクト: hugoware/CSMongo
        /// <summary>
        /// Selects the records from the database that matches this query
        /// </summary>
        public IEnumerable<MongoDocument> Select(int skip, int take, QueryOptionTypes options, params string[] fields)
        {
            //create the request to use
            QueryRequest request = new QueryRequest(this.Collection);
            request.Fields.AddRange(fields);
            request.Skip = skip;
            request.Take = take;
            request.Options = options;
            request.Parameters = this._Parameters;

            //send the request and get the response
            QueryResponse response = this.Collection.Database.Connection
                .SendRequest(request) as QueryResponse;

            //save this cursor for later
            MongoCursor cursor = new MongoCursor(request, response.CursorId, response.TotalReturned);
            this.Collection.Database.RegisterCursor(cursor);

            //and return the records
            IEnumerable<MongoDocument> documents = response.Documents.AsEnumerable();
            this.Collection.UpdateOnSubmit(documents);
            return documents;
        }
コード例 #3
0
ファイル: MongoQuery.cs プロジェクト: hugoware/CSMongo
 /// <summary>
 /// Selects only one document with the provided parameters
 /// </summary>
 public MongoDocument SelectOne(QueryOptionTypes options)
 {
     return this.SelectOne(Mongo.DefaultSkipCount, QueryOptionTypes.None);
 }
コード例 #4
0
ファイル: MongoQuery.cs プロジェクト: hugoware/CSMongo
 /// <summary>
 /// Selects the records from the database that matches this query
 /// </summary>
 public IEnumerable<MongoDocument> Select(QueryOptionTypes options, params string[] fields)
 {
     return this.Select(Mongo.DefaultSkipCount, Mongo.DefaultTakeCount, options, fields);
 }