我已經避免使用fetchxml,因爲我不確定調用crmService.Fetch(fetchXml)後處理結果數據的最佳方式。在一對夫婦的情況下,我已經使用LINQ一個XDocument來檢索該數據結構中的數據,如:你如何處理fetchxml結果數據?
XDocument resultset = XDocument.Parse(_service.Fetch(fetchXml));
if (resultset.Root == null || !resultset.Root.Elements("result").Any())
{
return;
}
foreach (var displayItem in resultset.Root.Elements("result").Select(item => item.Element(displayAttributeName)).Distinct())
{
if (displayItem!= null && displayItem.Value != null)
{
dropDownList.Items.Add(displayItem.Value);
}
}
什麼是處理fetchxml結果數據的最佳方式,以便它可以很容易地使用。諸如將這些記錄傳遞到ASP.NET數據網格等應用程序將非常有用。
是的,我一直主要使用RetrieveMultiple,但在這種情況下,我需要檢索一些屬性並添加一些基於聯合實體的條件,fetchXml允許我這樣做,並且QueryExpression對象不允許。 – 2009-07-31 01:52:37
盧克,你確定嗎?通過QueryExpression檢索也可以定義聯接。 – okutane 2009-07-31 02:04:10
是的,你可以定義連接,但我相當肯定你不能從一個連接的實體返回屬性。 – 2009-07-31 02:29:09