我已经得到父子关系中的实体类型。使用ExecuteTransactionRequest创建相关实体
由于ExecuteTransactionRequest
执行多个消息请求一个 tranasaction,会按照我的意愿去做以下工作吗?
有3个父母没有孩子下手:
//Create a 4th parent
cs_parent parent4 = new cs_parent{ cs_name = "p4" };
CreateRequest createParentRequest = new CreateRequest { Target = parent4 };
request.Requests.Add(createParentRequest);
EntityCollection parents
= context.RetrieveMultiple(/*fetchExpression to get all parents (I'm expecting 4 now)*/);
//Create a child for each parent
foreach (var p in parents.Entities)
{
cs_child child = new cs_child
{
cs_parentid = p.ToEntityReference();
}
CreateRequest createChildRequest = new CreateRequest { Target = child };
request.Requests.Add(createChildRequest);
}
response = (ExecuteTransactionResponse)context.Execute(request);
会我会得到4对父母有一个孩子每次话,还是只有3当我取回多以来,第四一个不是招”尚未创建(?)?
如果不是,我该如何修改我的代码仍然是一个Execute
命令在最后?