码迷,mamicode.com
首页 > 其他好文 > 详细

Microsoft dynamic 批量更新

时间:2017-08-25 10:52:52      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:collect   upd   exec   multi   service   mic   处理   cti   turn   

            //批量处理
            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();
            }

 

Microsoft dynamic 批量更新

标签:collect   upd   exec   multi   service   mic   处理   cti   turn   

原文地址:http://www.cnblogs.com/longdb/p/7426679.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!