Quantcast
Channel: Microsoft Dynamics CRM
Viewing all articles
Browse latest Browse all 154803

Forum Post: RE: How to get count of records of say contact entity using C#

$
0
0
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; } }

Viewing all articles
Browse latest Browse all 154803

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>