当前位置: 首页>>代码示例>>C#>>正文


C# BsonDocument.Remove方法代码示例

本文整理汇总了C#中BsonDocument.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# BsonDocument.Remove方法的具体用法?C# BsonDocument.Remove怎么用?C# BsonDocument.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BsonDocument的用法示例。


在下文中一共展示了BsonDocument.Remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RawData

 public RawData(BsonDocument bsonDocument)
 {
     TimestampSent = bsonDocument["timestamp_sent"].ToUniversalTime();
     bsonDocument.Remove("timestamp_sent");
     TimestampReceived = bsonDocument["timestamp_received"].ToUniversalTime();
     bsonDocument.Remove("timestamp_received");
     _sensorsDatas = BsonSerializer.Deserialize<SensorData>(bsonDocument);
 }
开发者ID:CRIAAC,项目名称:MongoDBDatasetConverter,代码行数:8,代码来源:RawData.cs

示例2: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            if (document.Contains("MaxErrors"))
                document.Remove("MaxErrors");

            if (document.Contains("MaxErrorsPerStack"))
                document.Remove("MaxErrorsPerStack");

            collection.Save(document);
        }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:9,代码来源:v1.0.19.cs

示例3: UpdateDocument

 public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document)
 {
     var projectIds = document.GetValue("ProjectIds").AsBsonArray.Select(p => p.AsInt32).ToList();
     document.Remove("ProjectIds");
     document.Add("ProjectIds", new BsonArray(projectIds.Select(x => x.ToString())));
     collection.Save(document);
 }
开发者ID:apxnowhere,项目名称:Encore,代码行数:7,代码来源:ChangeFieldProjectIdToString.cs

示例4: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document)
        {
            if (document.Contains("ErrorCount"))
                document.ChangeName("ErrorCount", "EventCount");

            if (document.Contains("TotalErrorCount"))
                document.ChangeName("TotalErrorCount", "TotalEventCount");

            if (document.Contains("LastErrorDate"))
                document.ChangeName("LastErrorDate", "LastEventDate");

            if (document.Contains("MaxErrorsPerMonth"))
                document.ChangeName("MaxErrorsPerMonth", "MaxEventsPerMonth");

            if (document.Contains("SuspensionCode")) {
                var value = document.GetValue("SuspensionCode");
                document.Remove("SuspensionCode");

                SuspensionCode suspensionCode;
                if (value.IsString && Enum.TryParse(value.AsString, true, out suspensionCode))
                    document.Set("SuspensionCode", suspensionCode);
            }

            collection.Save(document);
        }
开发者ID:arpitgold,项目名称:Exceptionless,代码行数:25,代码来源:v1.0.32.cs

示例5: InsertAnimals

        public static async void InsertAnimals(IMongoDatabase db)
        {
            //var client = new MongoClient();
            //var db = client.GetDatabase("test");

            var animals = db.GetCollection<BsonDocument>("animals");

            var animal = new BsonDocument
                            {
                            {"animal", "monkey"}
                            };

            try
            {
                await animals.InsertOneAsync(animal);
                animal.Remove("animal");
                animal.Add("animal", "cat");
                await animals.InsertOneAsync(animal);
                animal.Remove("animal");
                animal.Add("animal", "lion");
                await animals.InsertOneAsync(animal);
            }
            catch (Exception ex)
            {
                Console.WriteLine("ErroredOut", ex.Message.ToString());
            }
           

            var count = 0;
            var filter = new BsonDocument();
            using (var cursor = await animals.FindAsync(filter))
            {
                while (await cursor.MoveNextAsync())
                {
                    var batch = cursor.Current;
                    foreach (var document in batch)
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine("Total Count {0}", count);



        }
开发者ID:ashokkumarreddy1987,项目名称:learnings,代码行数:47,代码来源:Program.cs

示例6: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            if (collection.IndexExistsByName("Username_1"))
                collection.DropIndexByName("Username_1");

            if (document.Contains("Username"))
                document.Remove("Username");

            collection.Save(document);
        }
开发者ID:Ripper555,项目名称:Exceptionless,代码行数:9,代码来源:v1.0.16.cs

示例7: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            if (document.Contains("ErrorCount"))
                document.ChangeName("ErrorCount", "EventCount");

            if (document.Contains("TotalErrorCount"))
                document.ChangeName("TotalErrorCount", "TotalEventCount");

            if (document.Contains("LastErrorDate"))
                document.ChangeName("LastErrorDate", "LastEventDate");

            if (document.Contains("MaxErrorsPerDay")) {
                int maxErrorsPerDay = -1;
                var maxErrorsPerDayElement = document.GetValue("MaxErrorsPerDay");
                if (maxErrorsPerDayElement.IsInt32)
                    maxErrorsPerDay = maxErrorsPerDayElement.AsInt32;
                else if (maxErrorsPerDayElement.IsInt64)
                    maxErrorsPerDay = (int)maxErrorsPerDayElement.AsInt64;

                document.Set("MaxEventsPerMonth", maxErrorsPerDay > 0 ? maxErrorsPerDay * 30 : -1);
                document.Remove("MaxErrorsPerDay");
            }

            if (document.Contains("MaxErrorsPerMonth"))
                document.ChangeName("MaxErrorsPerMonth", "MaxEventsPerMonth");

            if (document.Contains("SuspensionCode")) {
                var value = document.GetValue("SuspensionCode");
                document.Remove("SuspensionCode");

                SuspensionCode suspensionCode;
                if (value.IsString && Enum.TryParse(value.AsString, true, out suspensionCode))
                    document.Set("SuspensionCode", suspensionCode);
            }

            if (document.Contains("PlanId")) {
                string planId = document.GetValue("PlanId").AsString;
                var currentPlan = BillingManager.GetBillingPlan(planId);

                document.Set("PlanName", currentPlan != null ? currentPlan.Name : planId);
                document.Set("PlanDescription", currentPlan != null ? currentPlan.Description : planId);
            }

            collection.Save(document);
        }
开发者ID:aamarber,项目名称:Exceptionless,代码行数:44,代码来源:v1.0.32.cs

示例8: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            if (document.Contains("oid")) {
                var organizationId = document.GetValue("oid").AsNullableObjectId;
                if (!organizationId.HasValue || organizationId.Value == ObjectId.Empty) {
                    document.Remove("oid");
                } else {
                    var organizationCollection = Database.GetCollection("organization");
                    var organization = organizationCollection.FindOneById(organizationId);

                    // The organization with this id could not be found.. Remove the webhook.
                    if (organization == null) {
                        collection.Remove(Query.EQ("_id", document.GetDocumentId()));
                        return;
                    }
                }
            }

            var projectCollection = Database.GetCollection("project");
            if (document.Contains("pid")) {
                var projectId = document.GetValue("pid").AsNullableObjectId;
                if (!projectId.HasValue || projectId.Value == ObjectId.Empty) {
                    document.Remove("pid");
                } else {
                    var project = projectCollection.FindOneById(projectId);

                    // The project with this id could not be found.. Remove the webhook.
                    if (project == null) {
                        collection.Remove(Query.EQ("_id", document.GetDocumentId()));
                        return;
                    }

                    if (!document.Contains("oid"))
                        document.Set("oid", project.GetValue("oid").AsObjectId);
                }
            }

            if (!document.Contains("oid") && !document.Contains("pid")) {
                collection.Remove(Query.EQ("_id", document.GetDocumentId()));
                return;
            }

            collection.Save(document);
        }
开发者ID:aamarber,项目名称:Exceptionless,代码行数:43,代码来源:v1.0.37.cs

示例9: CreateJsonFile

 private static void CreateJsonFile(string jsonReportsDirectory, BsonDocument report)
 {
     report.Remove("_id");
     BsonValue productIdAsBson;
     report.TryGetValue("product-id", out productIdAsBson);
     using (var file = new StreamWriter(jsonReportsDirectory + productIdAsBson.AsInt32 + ".json"))
     {
         file.WriteLine(report.ToJson());
     }
 }
开发者ID:TeamMojito,项目名称:SupermarketsDatabaseClient,代码行数:10,代码来源:MongoDBConnector.cs

示例10: Execute

        public void Execute(BsonDocument doc)
        {
            var occurance = new BsonDocument(doc.GetElement("time"),
                                             doc.GetElement("details"));
            doc.Remove("time");
            doc.Remove("details");

            var query = Query.And(Query.EQ("token", doc["token"]),
                                  Query.EQ("hash", doc["hash"]));

            UpdateBuilder ub = new UpdateBuilder();
            ub.Push("occurances", occurance);
            ub.Set("token", doc["token"]);
            ub.Set("hash", doc["hash"]);
            ub.Set("level", doc["level"]);
            ub.Set("common", doc["common"]);
            ub.Set("lastTime", occurance["time"]);

            Events.Update(query, ub, UpdateFlags.Upsert);
        }
开发者ID:jpoehls,项目名称:canary-dotnet,代码行数:20,代码来源:InsertEventAction.cs

示例11: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            if (document.Contains("OverageDays"))
                document.Remove("OverageDays");

            document.ChangeName("MaxErrorsPerDay", "MaxErrorsPerMonth");
            var maxErrorsPerMonth = document.GetValue("MaxErrorsPerMonth").AsInt32;
            if (maxErrorsPerMonth > 0)
                document.Set("MaxErrorsPerMonth", maxErrorsPerMonth * 30);

            collection.Save(document);
        }
开发者ID:jrheault,项目名称:Exceptionless,代码行数:11,代码来源:v1.0.29.cs

示例12: Change

        public void Change(ObjectId id, BsonDocument changes)
        {
            var builder = Builders<BsonDocument>.Update;
            var changeDefinitions = new List<UpdateDefinition<BsonDocument>>();

            changes.Remove("_id");

            changes.Elements.ToList().ForEach(element =>
            {
                changeDefinitions.Add(builder.Set(element.Name, element.Value));
            });

            Change(id, builder.Combine(changeDefinitions));
        }
开发者ID:r0flbear,项目名称:MongoInterface,代码行数:14,代码来源:Document.cs

示例13: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            if (document.Contains("OrganizationId"))
                document.ChangeName("OrganizationId", "oid");
            
            if (document.Contains("ProjectId"))
                document.ChangeName("ProjectId", "pid");

            if (document.Contains("Version"))
                document.Remove("Version");

            document.Set("Version", "1.0.0.0");

            collection.Save(document);
        }
开发者ID:aamarber,项目名称:Exceptionless,代码行数:14,代码来源:v1.0.36.cs

示例14: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            if (document.Contains("EmailNotificationsEnabled")) {
                bool emailNotificationsEnabled = document.GetValue("EmailNotificationsEnabled").AsBoolean;
                while (document.Contains("EmailNotificationsEnabled"))
                    document.Remove("EmailNotificationsEnabled");

                document.Set("EmailNotificationsEnabled", emailNotificationsEnabled);
            }

            if (document.Contains("EmailAddress")) {
                string emailAddress = document.GetValue("EmailAddress").AsString;
                if (!String.IsNullOrWhiteSpace(emailAddress))
                    document.Set("EmailAddress", emailAddress.ToLowerInvariant().Trim());
            }

            collection.Save(document);
        }
开发者ID:aamarber,项目名称:Exceptionless,代码行数:17,代码来源:v1.0.34.cs

示例15: UpdateDocument

        public override void UpdateDocument(MongoCollection<BsonDocument> collection, BsonDocument document) {
            var errorRepository = new ErrorRepository(collection.Database, null, null, null);
            BsonValue id = document.GetDocumentId();
            if (id == null || !id.IsObjectId)
                return;

            Error error = errorRepository.GetById(id.ToString());
            if (error == null)
                return;

            if (document.Contains("sig"))
                document.Remove("sig");

            var signatureFactory = new ErrorSignatureFactory();
            // updates the document to set the IsSignatureTarget
            ErrorSignature signature = signatureFactory.GetSignature(error);
            errorRepository.Update(error);
        }
开发者ID:khoussem,项目名称:Exceptionless,代码行数:18,代码来源:v1.0.11_Migration.cs


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