仅在C#中为MongoDB更新嵌套数组中的必填字段

时间:2019-02-12 13:56:33

标签: c# arrays mongodb nested

{

   "DistributionChannel":[
      {
         "ChannelNumber":0,
         "Title":"Direct-Primary",
         "TargetClasses" : [
                {
                    "ClassID" : "T00000001",
                    "TypeOfRisk" : "<p>Test 1&nbsp;Accountants</p>\n"
                },
                {
                    "ClassID" : "T00000002",
                    "TypeOfRisk" : "<p>Test 2&nbsp;Agents</p>\n"
                }
            ],
         "IneligibleClasses" : [
                {
                    "ClassID" : "T283373"
                },
                {
                    "ClassID" : "T00000005"
                }
            ],
         "EligibleCountries":null,
         "EligibleStates":null,
         "IneligibleStates":null,
         "OtherGeoExclusions":null,
         "AggregateLimits":"1000",
         "OccurrenceLimits":null,
         "MinimumPremium":null,
         "UnderwritingVerticalID":"",
         "UnderwritingVertical":null,
         "IssuingPapers" : [
                {
                    "IssuingPaperID" : "IP000001"
                },
                {
                    "IssuingPaperID" : "IP000002"
                }
            ],
         "DistributionMethod":[
            {
               "DMID":"DM000001",
               "DM":"Direct"
            }
         ],
         "ParticipationLayerID":"PLC000002",
         "ParticipationLayer":"Primary",
         "RiskComplexityTypeID":"",
         "RiskComplexityType":null,
         "Submission":null,
         "CustomHierarchy":false,
         "StateWide":null,
         "RegionWide":null,
         "NationWide":null,
         "Leadership":null,
         "Applications":null
      }
   ],
   "ProductState":null,
   "MarkelProductInitiation":null,
   "ProducerExclusivity":null,
   "TopProducer":null,
   "TopRecentDeals":null,
   "PremiumVolumeByCalendarYear":null,
   "PremiumProjectionByCalendarYear":null,
   "KeyCompetitors":null,
   "StateOfMarket":null,
   "TargetsOfOpportunity":null,
   "ImportantConferences":null,
   "UnderwritingGuidelinesDoc":null,
   "UnderwritingGuidanceWebsites":null,
   "ProducerCommisionArrangements":null,
   "BillingPaymentOptions":null,
   "PeakUnderwritingSeason":null,
   "AutoDecisionGoals":null,
   "QuotingSLA":null,
   "CommonDeclines":null,
   "CompetitorApplications":null,
   "StartUps":null,
   "Status":"submit",
   "Role":null,
   "Comments":null,
   "ChangedFields":[

      {

        "FieldName":"Name",
         "IsApproved" : true,
         "ChangedStatus":[
            {
               "Status":"4",
               "Indexes":0,
               "NestedField":null
            }
         ]
      },
      {
         "FieldName":"Quoting",
         "IsApproved" : true,

         "ChangedStatus":[
            {
               "Status":"5",
               "Indexes":0,
               "NestedField":null
            }
         ]
      },
      {
         "FieldName":"ProductWebsite",
         "IsApproved" : false,
         "ChangedStatus":[
            {
               "Status":"4",
               "Indexes":0,
               "NestedField":null
            }
         ]
      },

      {
         "FieldName":"CrossSellProduct",
         "IsApproved" : true,
         "ChangedStatus":
         [
            {
               "Status":"4",
               "Indexes":0,
               "NestedField":null
            },
            {
               "Status":"4",
               "Indexes":0,
               "NestedField":null
            },
            {
               "Status":"4",
               "Indexes":0,
               "NestedField":null
            }

         ]
      },

       {
         "FieldName":"MarketingProductMaterial",
         "IsApproved" : true,
         "ChangedStatus":
         [
            {
               "Status":"4",
               "Indexes":0,
               "NestedField":null
            },
            {
               "Status":"4",
               "Indexes":0,
               "NestedField":null
            },
            {
               "Status":"4",
               "Indexes":0,
               "NestedField":null
            }

         ]
      },


      {

  "FieldName": "DistributionChannel",
  "IsApproved": false,
  "ChangedStatus": [
    {
      "Status": 2,
      "Ischanged": true,
      "Indexes": 0,
      "NestedField": [
        {
          "FieldName": "TargetClasses",
          "IsApproved": true,
          "ChangedStatus": [
            {
              "Status": 1,
              "Ischanged": true,
              "Indexes": 2,
              "NestedField": null
            },
            {
              "Status": 1,
              "Ischanged": true,
              "Indexes": 2,
              "NestedField": null
            }
          ]
        },

        {
          "FieldName": "IssuingPapers",
          "IsApproved": true,
          "ChangedStatus": [
            {
              "Status": 1,
              "Ischanged": true,
              "Indexes": 2,
              "NestedField": null
            },
            {
              "Status": 1,
              "Ischanged": true,
              "Indexes": 2,
              "NestedField": null
            }
          ]
        },

        {
          "FieldName": "IneligibleClasses",
          "IsApproved": false,
          "ChangedStatus": [
            {
              "Status": 1,
              "Ischanged": true,
              "Indexes": 2,
              "NestedField": null
            },
            {
              "Status": 1,
              "Ischanged": true,
              "Indexes": 2,
              "NestedField": null
            }
          ]
        },

        {
          "FieldName": "AggregateLimits",
          "IsApproved": true,
          "ChangedStatus": [
            {
              "Status": 1,
              "Ischanged": true,
              "Indexes": 2,
              "NestedField": null
            }

          ]








        }







      ]




    }
  ]
}

   ],
   "id":"5c49980d4825a541a04c6d02",
   "CreatedDate":"2019-01-31T09:03:25.653Z",
   "UpdatedDate":"2019-01-31T09:06:15.892Z",
   "CreatedBy":"EMP012",
   "UpdatedBy":null

}

不是,我只想根据领域名称从嵌套的领域更新“ TargetClasses”。

1 个答案:

答案 0 :(得分:0)

您应该创建此对象的类,对其进行反序列化并在C#中使用它。