web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Add Record To Entity Collection

(1) ShareShare
ReportReport
Posted on by

Hello,

I want to add a record (let's call it "sampleRecord") to an Entity Collection (let's call it "sampleCollection"), but somehow I can't make it work. I found this solution on the internet, but when I check the total record count via ITracingService, it's still 0.

my solution so far:

EntityCollection sampleCollection = new EntityCollection();
sampleCollection.Entities.Add(sampleRecord);

and that's how I checked the total record count:

tracingService.Trace("total record count: " + sampleCollection.TotalRecordCount.ToString());

Thanks in advance for any help!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    ashlega Profile Picture
    34,477 on at

    Hi Nathalie,

     I believe TotalRecordCount is referring to the overall number of records when you are receiving that data from the server (for example, with paging you can have 25 record per request, but your total can be 2000)

     In your scenario, try another property:

     sampleCollection.Entities.Count

  • Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Where do you create the sampleRecord?

    Did you check that sampleRecord is not null?

    As suggested by Alex it should be:

    sampleCollection.Entities.count

               

  • Community Member Profile Picture
    on at

    thanks a lot - that fixed my problem!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans