• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# IMongoQuery类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IMongoQuery的典型用法代码示例。如果您正苦于以下问题:C# IMongoQuery类的具体用法?C# IMongoQuery怎么用?C# IMongoQuery使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IMongoQuery类属于命名空间,在下文中一共展示了IMongoQuery类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
                }
            });
        }
开发者ID:BernhardGlueck,项目名称:Phare,代码行数:35,代码来源:OsmEntityExtractor.cs


示例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;
        }
开发者ID:269378737,项目名称:extractsystem,代码行数:32,代码来源:GysExtractManage.cs


示例3: MongoDeleteMessage

 // constructors
 internal MongoDeleteMessage(BsonBinaryWriterSettings writerSettings, string collectionFullName, RemoveFlags flags, IMongoQuery query)
     : base(MessageOpcode.Delete, null, writerSettings)
 {
     _collectionFullName = collectionFullName;
     _flags = flags;
     _query = query;
 }
开发者ID:moonreplace,项目名称:mongo-csharp-driver,代码行数:8,代码来源:MongoDeleteMessage.cs


示例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;
        }
开发者ID:BernhardGlueck,项目名称:Phare,代码行数:25,代码来源:OsmEntityTagsExtractor.cs


示例5: Remove

        public bool Remove(IMongoQuery query)
        {
            if (query == null)
                throw new ArgumentNullException("Collection must not be null");

            return _connection.GetCurrentCollection().Remove(query).Ok;
        }
开发者ID:jsouthron,项目名称:nosql,代码行数:7,代码来源:NoSqlRemover.cs


示例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();
        }
开发者ID:BernhardGlueck,项目名称:Phare,代码行数:8,代码来源:OsmDatabaseExtensions.cs


示例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);
 }
开发者ID:269378737,项目名称:go81,代码行数:9,代码来源:新闻管理.cs


示例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;
 }
开发者ID:kamaradclimber,项目名称:mongo-csharp-driver,代码行数:10,代码来源:MongoUpdateMessage.cs


示例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;
 }
开发者ID:kamaradclimber,项目名称:mongo-csharp-driver,代码行数:10,代码来源:MongoQueryMessage.cs


示例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;
        }
开发者ID:jsouthron,项目名称:nosql,代码行数:10,代码来源:QueryConstants.cs


示例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();
        }
开发者ID:lgadi,项目名称:ZeeBi,代码行数:10,代码来源:StatsController.cs


示例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)
 {
 }
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:12,代码来源:MongoQueryMessage.cs


示例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) {
 }
开发者ID:ebix,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoQueryMessage.cs


示例14: SetQuery

 public void SetQuery(IMongoQuery mongoQuery)
 {
     if (this.MongoQuery != null)
     {
         this.MongoQuery = QueryBuilder.Query.And(this.MongoQuery, mongoQuery);
     }
     else
     {
         this.MongoQuery = mongoQuery;
     }
 }
开发者ID:kooboo-jifeng,项目名称:CMS,代码行数:11,代码来源:MongoDBVisitor.cs


示例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;
 }
开发者ID:ebix,项目名称:mongo-csharp-driver,代码行数:11,代码来源:MongoDeleteMessage.cs


示例16: OsmCompoundQuery

        public static IEnumerable<OsmEntity> OsmCompoundQuery(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);

            PrepareCursorForBatchProcessing(r1);
            PrepareCursorForBatchProcessing(r2);
            PrepareCursorForBatchProcessing(r3);

            return r1.Cast<OsmEntity>().Concat(r2).Concat(r3);
        }
开发者ID:BernhardGlueck,项目名称:Phare,代码行数:12,代码来源:OsmDatabaseExtensions.cs


示例17: RemoveOperation

 public RemoveOperation(
     string databaseName,
     string collectionName,
     BsonBinaryReaderSettings readerSettings,
     BsonBinaryWriterSettings writerSettings,
     WriteConcern writeConcern,
     IMongoQuery query,
     RemoveFlags flags)
     : base(databaseName, collectionName, readerSettings, writerSettings, writeConcern)
 {
     _query = query;
     _flags = flags;
 }
开发者ID:einaregilsson,项目名称:mongo-csharp-driver,代码行数:13,代码来源:RemoveOperation.cs


示例18: MongoUpdateMessage

 internal MongoUpdateMessage(
     MongoConnection connection,
     string collectionFullName,
     UpdateFlags flags,
     IMongoQuery query,
     IMongoUpdate update
 ) :
     base(connection, MessageOpcode.Update) {
     this.collectionFullName = collectionFullName;
     this.flags = flags;
     this.query = query;
     this.update = update;
 }
开发者ID:oskysal,项目名称:mongo-csharp-driver,代码行数:13,代码来源:MongoUpdateMessage.cs


示例19: WrapQuery

        protected IMongoQuery WrapQuery(IMongoQuery query, BsonDocument options, ReadPreference readPreference, bool forShardRouter)
        {
            BsonDocument formattedReadPreference = null;
            if (forShardRouter && readPreference != null && readPreference.ReadPreferenceMode != ReadPreferenceMode.Primary)
            {
                BsonArray tagSetsArray = null;
                if (readPreference.TagSets != null)
                {
                    tagSetsArray = new BsonArray();
                    foreach (var tagSet in readPreference.TagSets)
                    {
                        var tagSetDocument = new BsonDocument();
                        foreach (var tag in tagSet)
                        {
                            tagSetDocument.Add(tag.Name, tag.Value);
                        }
                        tagSetsArray.Add(tagSetDocument);
                    }
                }

                if (tagSetsArray != null || readPreference.ReadPreferenceMode != ReadPreferenceMode.SecondaryPreferred)
                {
                    formattedReadPreference = new BsonDocument
                    {
                        { "mode", MongoUtils.ToCamelCase(readPreference.ReadPreferenceMode.ToString()) },
                        { "tags", tagSetsArray, tagSetsArray != null } // optional
                    };
                }
            }

            if (options == null && formattedReadPreference == null)
            {
                return query;
            }
            else
            {
                var queryDocument = (query == null) ? (BsonValue)new BsonDocument() : BsonDocumentWrapper.Create(query);
                var wrappedQuery = new QueryDocument
                {
                    { "$query", queryDocument },
                    { "$readPreference", formattedReadPreference, formattedReadPreference != null }, // only if sending query to a mongos
                };
                if (options != null)
                {
                    wrappedQuery.Merge(options);
                }
                return wrappedQuery;
            }
        }
开发者ID:GGsus,项目名称:mongo-csharp-driver,代码行数:49,代码来源:ReadOperationBase.cs


示例20: Random

        public static List<专家> 抽选专家(int count, IMongoQuery conditions, IEnumerable<long> selected, IEnumerable<long> avoid, string 所属单位)
        {
            var ret = new List<专家>(count);
            var rnd = new Random();

            var now = DateTime.Now;
            //筛选条件,专家3个月内不能被同一单位抽取,一年内不能被同一单位抽取3次
            var querydate = Query.Where(
                        " function(){" +
                        " var count = obj.历史抽取信息." + 所属单位 + ".length;" +
                        " if (count == 0) return true;" +
                        " if (count >0 && count <3 && new Date(obj.历史抽取信息." + 所属单位 + "[count-1]) < new Date(\"" + now.AddMonths(-3).ToString() + "\")) return true;" +
                        " if (count >=3 &&  new Date(obj.历史抽取信息." + 所属单位 + "[count-1]) < new Date(\"" + now.AddMonths(-3).ToString() + "\") && new Date(obj.历史抽取信息." + 所属单位 + "[count-3]) < new Date(\"" + now.AddYears(-1).ToString() + "\")) return true;" +
                        " return false;" +
                        " }");
            var q = Query<专家>.EQ(o => o.审核数据.审核状态, 审核状态.审核通过).And(Query.NotExists("历史抽取信息." + 所属单位).Or(querydate));
            if (null != conditions)
                conditions = Query.And(conditions, q);
            else
                conditions = q;

            if (null != selected && 0 != selected.Count())
            {
                q = Query.NotIn("_id", new BsonArray(selected));
                conditions = Query.And(conditions, q);
            }
            if (null != avoid && 0 != avoid.Count())
            {
                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;
        }
开发者ID:269378737,项目名称:go81,代码行数:47,代码来源:专家抽选管理.cs



注:本文中的IMongoQuery类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IMoniker类代码示例发布时间:2022-05-24
下一篇:
C# IMongoDatabase类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap