Here it is : - private void btnUpdate_Click(object sender, EventArgs e) { string fetchXml = @" "; MessageBox.Show($"Count of Records:{totalCount.Entities.Count}"); } public static int GetRecordCount(string fetchXml, string attributeName, ConditionExpression expression) { int rc = 0; StringBuilder sb = new StringBuilder(); sb.AppendLine(" "); sb.AppendLine(" "); sb.AppendLine(" "); sb.AppendLine(" "); if (expression.Values.Count > 1) { sb.AppendLine(" "); for (int i = 0; i " + expression.Values[i].ToString() + " "); } sb.AppendLine(" "); } else { sb.AppendLine(" "); } sb.AppendLine(" "); sb.AppendLine(" "); sb.AppendLine(" "); sb.AppendLine(" "); EntityCollection totalCount = _service.RetrieveMultiple(new FetchExpression(sb.ToString())); if (totalCount.Entities.Count > 0) { foreach (var t in totalCount.Entities) { rc = (int)((AliasedValue)t[attributeName + "_count"]).Value; break; } } return rc; } }
↧