You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
2.0 KiB
59 lines
2.0 KiB
/* Copyright 2010-2011 10gen Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Text;
|
|
using System.Threading;
|
|
|
|
namespace MongoDB.Driver.Linq {
|
|
/// <summary>
|
|
/// Represents a LINQ query that has been translated to an equivalent MongoDB Find query.
|
|
/// </summary>
|
|
public class MongoLinqFindQuery : MongoLinqQuery {
|
|
#region private fields
|
|
private IMongoQuery query;
|
|
#endregion
|
|
|
|
#region constructor
|
|
/// <summary>
|
|
/// Initializes a new instance of the MongoLinqFindQuery class.
|
|
/// </summary>
|
|
/// <param name="collection">The collection being queried.</param>
|
|
/// <param name="query">The query.</param>
|
|
public MongoLinqFindQuery(
|
|
MongoCollection collection,
|
|
IMongoQuery query
|
|
)
|
|
: base(collection) {
|
|
this.query = query;
|
|
}
|
|
#endregion
|
|
|
|
#region public methods
|
|
/// <summary>
|
|
/// Executes the translated Find query.
|
|
/// </summary>
|
|
/// <returns>The result of executing the translated Find query.</returns>
|
|
public override IEnumerator<T> GetEnumerator<T>() {
|
|
var cursor = collection.FindAs<T>(query);
|
|
// TODO: modify the cursor with things like sort order, skip and limit
|
|
return cursor.GetEnumerator();
|
|
}
|
|
#endregion
|
|
}
|
|
}
|