0
我有一個像下面的代碼:微軟CRM QueryExpression在C#
QueryExpression query = new QueryExpression();
query.EntityName = "new_callistyorder";
ColumnSet col = new ColumnSet("new_nomororder","new_customer");
query.ColumnSet = col;
EntityCollection colect = service.RetrieveMultiple(query);
string str = string.Empty;
foreach (Entity e in colect.Entities)
{
if(e.Contains("new_nomororder")){
str = str + e.Attributes["new_nomororder"].ToString();
}
}
throw new InvalidPluginExecutionException(str);
海槽此代碼。我能夠從微軟動態實體獲取數據。 現在,我想獲得最大的id的數據。 如果在SQL查詢中,它將看起來像這樣:「通過my_id desc從帳戶順序中選擇top 1 my_id」。 我該怎麼做queryexpression? 感謝
感謝馬可, 我能問你一個問題嗎? 我該如何檢查queryexpression是否包含數據。 我被認爲使用「TotalRecordCount」。這是真的嗎? –
執行檢索後,假設您將實體存儲在名爲retrieveEntities的變量中,您可以使用retrieveEntities.Entities.Count – MaPi
檢查集合的大小,我不明白:if(colect.TotalRecordCount <1) { entity [「new_nomororder」] =「ODR-C7HI-001」; } else { string str = string.Empty; (e.Contains(「new_nomororder」)) { str = str + e.Attributes [「new_nomororder」]。ToString(); } }' 我想設置字段值如果查詢表達式dosn; t包含數據 –