本文整理汇总了C#中IMongoQuery类的典型用法代码示例。如果您正苦于以下问题:C# IMongoQuery类的具体用法?C# IMongoQuery怎么用?C# IMongoQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMongoQuery类属于命名空间,在下文中一共展示了IMongoQuery类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Extract
public IObservable<ParkingArea> Extract(IMongoQuery query)
{
return Observable.Create<ParkingArea>(async observer =>
{
var totalEntitiesToProcess = serverProvider.Database.OsmCompoundQueryCount(query);
var operationCounter = new OperationCounter(log, string.Format("OSM Parking Area Extraction from {0}",query), totalEntitiesToProcess);
var cursor = serverProvider.Database.OsmCompoundQuery(query);
foreach (var entity in cursor)
{
var entityContext = new OsmEntityContext(serverProvider.Database, entity);
var parkingArea = new ParkingArea() { Id = Guid.NewGuid(), Source = ParkingAreaSource.Maps, Confidence = configuration.Model.Confidence };
var isValid = true;
foreach (var extractionRule in extractionRules)
{
var continueExtraction = await extractionRule.Extract(entityContext, parkingArea);
if (!continueExtraction)
{
log.Info("Entity {0} was dropped from extraction by rule {1}", entity, extractionRule.GetType().Name.Replace("Extraction", string.Empty).Replace("Rule", string.Empty));
isValid = false;
break;
}
}
if (isValid)
{
observer.OnNext(parkingArea);
}
operationCounter.Increment();
}
});
}
示例2: Random
public static List<供应商> 抽选供应商(int count, IMongoQuery conditions, IEnumerable<long> selected, IEnumerable<long> avoid)
{
var ret = new List<供应商>(count);
var rnd = new Random();
conditions = conditions.And(Query<供应商>.EQ(o => o.审核数据.审核状态, 审核状态.审核通过));
if (null != selected && 0 != selected.Count())
{
var q = Query.NotIn("_id", new BsonArray(selected));
conditions = Query.And(conditions, q);
}
if (null != avoid && 0 != avoid.Count())
{
var q = Query.NotIn("_id", new BsonArray(avoid));
conditions = Query.And(conditions, q);
}
int total = (int)Mongo.计数<供应商>(0, 0, conditions);
if (total < count) return new List<供应商>();
var r = Mongo.查询<供应商>(0, 0, conditions);
var ns = new HashSet<int>();
for (int i = 0; i < count; i++)
{
int n;
do
{
n = rnd.Next(total);
} while (ns.Contains(n));
ret.Add(r.ElementAt(n));
ns.Add(n);
}
return ret;
}
示例3: MongoDeleteMessage
// constructors
internal MongoDeleteMessage(BsonBinaryWriterSettings writerSettings, string collectionFullName, RemoveFlags flags, IMongoQuery query)
: base(MessageOpcode.Delete, null, writerSettings)
{
_collectionFullName = collectionFullName;
_flags = flags;
_query = query;
}
示例4: GetAllTags
public IEnumerable<KeyValuePair<string, IEnumerable<string>>> GetAllTags(IMongoQuery query)
{
var dataSet = new Dictionary<string, HashSet<string>>(StringComparer.OrdinalIgnoreCase);
foreach (var entity in serverProvider.Database.OsmCompoundQuery(query))
{
foreach (var tag in entity.Tags)
{
if (!dataSet.ContainsKey(tag.Key))
{
dataSet.Add(tag.Key, new HashSet<string>(StringComparer.OrdinalIgnoreCase));
}
var valueSet = dataSet[tag.Key];
if (!valueSet.Contains(tag.Value))
{
valueSet.Add(tag.Value);
}
}
}
var result = dataSet.Select(kv => new KeyValuePair<string, IEnumerable<string>>(kv.Key, kv.Value));
return result;
}
示例5: Remove
public bool Remove(IMongoQuery query)
{
if (query == null)
throw new ArgumentNullException("Collection must not be null");
return _connection.GetCurrentCollection().Remove(query).Ok;
}
示例6: OsmCompoundQueryCount
public static long OsmCompoundQueryCount(this MongoDatabase database,IMongoQuery query)
{
var r1 = database.GetOsmCollection(OsmEntityType.Node).FindAs<OsmNode>(query);
var r2 = database.GetOsmCollection(OsmEntityType.Way).FindAs<OsmWay>(query);
var r3 = database.GetOsmCollection(OsmEntityType.Relation).FindAs<OsmRelation>(query);
return r1.Count() + r2.Count() + r3.Count();
}
示例7:
public static IEnumerable<新闻> 查询图片新闻(int skip, int limit, IMongoQuery conditions = null)
{
var q = Query.SizeGreaterThan("内容主体.图片", 0);
if (conditions != null)
{
q = q.And(conditions);
}
return Mongo.查询<新闻>(skip, limit,q , true, null, false, false);
}
示例8: MongoUpdateMessage
// constructors
internal MongoUpdateMessage(BsonBinaryWriterSettings writerSettings, string collectionFullName, bool checkUpdateDocument, UpdateFlags flags, IMongoQuery query, IMongoUpdate update)
: base(MessageOpcode.Update, null, writerSettings)
{
this.collectionFullName = collectionFullName;
this.checkUpdateDocument = checkUpdateDocument;
this.flags = flags;
this.query = query;
this.update = update;
}
示例9: MongoQueryMessage
internal MongoQueryMessage(BsonBuffer buffer, BsonBinaryWriterSettings writerSettings, string collectionFullName, QueryFlags flags, int numberToSkip, int numberToReturn, IMongoQuery query, IMongoFields fields)
: base(MessageOpcode.Query, buffer, writerSettings)
{
this.collectionFullName = collectionFullName;
this.flags = flags;
this.numberToSkip = numberToSkip;
this.numberToReturn = numberToReturn;
this.query = query;
this.fields = fields;
}
示例10: GeoQuery
public static IMongoQuery GeoQuery(MongoLocation loc, double prox, IMongoQuery query)
{
var locQuery = QueryConstants.GeoQuery(loc, prox);
var q = new QueryDocument();
q.AddRange(BsonDocument.Parse(locQuery.ToString()));
if (query != null) q.AddRange(BsonDocument.Parse(query.ToString()));
return q;
}
示例11: GetPageViewsByUserAgent
private ICollection<KeyValuePair<string, int>> GetPageViewsByUserAgent(IMongoQuery query)
{
var reduce = new BsonJavaScript("function(o, agg) { agg.count++; }");
var results = DB.PageViews.Group(query, "UserAgent", new { count = 0 }.ToBsonDocument(), reduce, null).ToList();
return results
.ToKeyValuePairs(x => x["UserAgent"].AsString, x => x["count"].ToInt32())
.OrderByDescending(kvp => kvp.Value)
.ToList();
}
示例12: MongoQueryMessage
// constructors
internal MongoQueryMessage(
BsonBinaryWriterSettings writerSettings,
string collectionFullName,
QueryFlags flags,
int numberToSkip,
int numberToReturn,
IMongoQuery query,
IMongoFields fields)
: this(null, writerSettings, collectionFullName, flags, numberToSkip, numberToReturn, query, fields)
{
}
示例13: MongoQueryMessage
internal MongoQueryMessage(
MongoServer server,
string collectionFullName,
QueryFlags flags,
int numberToSkip,
int numberToReturn,
IMongoQuery query,
IMongoFields fields
) :
this(server, collectionFullName, flags, numberToSkip, numberToReturn, query, fields, null) {
}
示例14: SetQuery
public void SetQuery(IMongoQuery mongoQuery)
{
if (this.MongoQuery != null)
{
this.MongoQuery = QueryBuilder.Query.And(this.MongoQuery, mongoQuery);
}
else
{
this.MongoQuery = mongoQuery;
}
}
示例15: MongoDeleteMessage
internal MongoDeleteMessage(
MongoServer server,
string collectionFullName,
RemoveFlags flags,
IMongoQuery query
) :
base(server, MessageOpcode.Delete) {
this.collectionFullName = collectionFullName;
this.flags = flags;
this.query = query;
}