我已經得到父子關係中的實體類型。使用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
命令在最後?