【MSCRM开发】更新一个实体函数

 

 1 public void UpdateEntity(ICrmService service)
 2 
 3 {
 4 
 5 //variable initialization
 6 
 7             DynamicEntity entity = new DynamicEntity();                                                     //target entity to update
 8 
 9             TargetUpdateDynamic targetUpdate = new TargetUpdateDynamic();      //used to update entity
10 
11             UpdateRequest updateRequest = new UpdateRequest();                            //request to update entity
12 
13 
14 
15 entity.Name = <entity name>
16 
17 
18 
19 //add the properties you want to update on the entity
20 
21 entity.Properties.Add(<property1>);
22 
23 entity.Properties.Add(<property2>);
24 
25 entity.Properties.Add(<property3>);
26 
27              
28 
29 //set the target to update, and the request to update for
30 
31 targetUpdate.Entity = entity;
32 
33 updateRequest.Target = targetUpdate;
34 
35 
36 
37 //execute the update request
38 
39 service.Execute(updateRequest);
40 
41 }
42 

 

 

参看:http://www.igooya.cn/bbs/viewthread.php?tid=469&extra=page%3D1

posted @ 2009-03-30 21:21  Eric's Yang  阅读(236)  评论(0编辑  收藏  举报