Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to retrieve all accounts from CRM in C#?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello! Right now I'm using the QuickStart project in Visual Studio that is provided by Microsoft to connect to Dynamics and retrieve/update/delete records, but there's one thing that I haven't found a solution for. Is there a way to select all accounts without using a unique value for reference (ex. user id, account name, email)? I need to be able to retrieve ALL of my accounts (which will never be above about 100 total). I would provide sample code for what I have tried, but I don't know where to start. I AM successfully connecting and I CAN retrieve accounts with unique identifiers.

*This post is locked for comments

  • RE: How to retrieve all accounts from CRM in C#?

    Maybe you're seeing deactivated accounts. Double check what view you're currently using.

    Just as a small suggestion, never use  new ColumnSet(true) because you'll fetch all fields and this is generally not wanted and it is also bad for performance.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to retrieve all accounts from CRM in C#?

    Nope, I'm logging in with the same user on both. I suppose I could try accessing the contents of each entity and printing them so I could see what the extra accounts are?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to retrieve all accounts from CRM in C#?

    Awesome! One more thing..  When I do Console.WriteLine(collAccounts.Entities.Count); it is printing out whatever the total number of accounts I have is, but with a constant 26 added to that. For example, if I delete all of the accounts, it prints 26. If I create 11 and run the program, it prints 37. Do you know where I could check to get rid of those extra accounts, or could you tell me what's causing this?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,307 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans