//批量处理 ExecuteMultipleRequest multipleRequest = new ExecuteMultipleRequest() { Settings = new ExecuteMultipleSettings() { ContinueOnError = false, ReturnResponses = false }, Requests = new OrganizationRequestCollection() }; //更新库存金额 for (int j = 0; j < ecIn.Entities.Count; j++) { ep_DyesChemicalsInventory Inventory = ecIn.Entities[j].ToEntity<ep_DyesChemicalsInventory>(); if (Inventory.GetAttributeValue<decimal>(inqty) <= 0 || Inventory.GetAttributeValue<Money>(inamount).Value <= 0) { continue; } Inventory.ep_Amount = new Money(Inventory.GetAttributeValue<decimal>(inqty) * price); updateRequest = new UpdateRequest { Target = Inventory }; multipleRequest.Requests.Add(updateRequest); //service.Update(objectentity); } if (multipleRequest.Requests.Count > 0) { service.Execute(multipleRequest);//批量更新 multipleRequest.Requests.Clear(); }